Alex Gleason 9d43fdbcc3 Use window.nostr.connect, getSigner and disconnect where the extension offers them
Din's and Tenna's NIP-07 providers add three optional methods, after NIP-46's
names. Logging in through an extension now asks connect() for an account
(skipping the Welcome back preview, since the extension shows the account),
each extension login signs through getSigner(pubkey) so switching accounts
in the extension doesn't change who the app signs as, and logging out calls
disconnect(pubkey). Each is feature-detected on its own; extensions without
them work as before. The onchain-bitcoin skill's NBrowserSignerBtc now
builds on the same signer.
2026-11-28 16:50:29 -06:00
2025-08-18 21:55:35 -05:00
2026-11-28 16:32:28 -06:00

MKStack

A template for building Nostr apps with AI agents. It's a working React app with login, relay management, publishing and file uploads already wired up, plus an AGENTS.md and a set of skills that teach coding agents how to build on it safely.

Stack

  • React 19 with TypeScript
  • Vite 8 for the dev server and build
  • Tailwind CSS 4 and shadcn/ui (Radix UI) components
  • Nostrify and nostr-tools for the Nostr protocol
  • TanStack Query for data fetching and caching
  • React Router 7
  • Vitest 5 with React Testing Library

Getting started

git clone https://gitlab.com/soapbox-pub/mkstack.git my-app
cd my-app
npm run dev

The dev server runs on localhost:8080. The dev, build and test scripts install dependencies themselves.

Command What it does
npm run dev Start the dev server
npm run build Build to dist/, with 404.html copied from index.html
npm test Type-check, lint, run the tests, then build

The template fails npm test on purpose

A fresh copy fails lint until it's made into a real app. The rules check for things every app needs, so an agent can't finish without them:

  • a <title>, a meta description and Open Graph tags in index.html
  • a web manifest at public/manifest.webmanifest
  • no FIXME comments left (the starter page and the font setup have them)

What's included

  • Login: LoginArea opens a dialog for signing up, a browser extension (NIP-07), a private key or a remote signer (NIP-46), and becomes an account switcher once logged in. Extension logins use the optional window.nostr.connect, getSigner and disconnect where the extension offers them (Din and Tenna do), so the app keeps signing as each login's own account when the user switches accounts in the extension.
  • Hooks: useCurrentUser, useAuthor, useNostrPublish, useUploadFile (Blossom), useLoggedInAccounts, useTheme, useIsMobile and others in src/hooks/.
  • Relays: a default relay pool, and the user's NIP-65 relay list loaded on login and published when it changes.
  • NIP-19 routing: npub, nprofile, note, nevent and naddr identifiers are routed at the URL root to src/pages/NIP19Page.tsx.
  • UI: about 50 shadcn/ui components in src/components/ui/, with light and dark themes.
  • Security defaults: a strict Content Security Policy in index.html and lint rules against inline scripts.

Building with an agent

AGENTS.md is the system prompt for agents working in a project made from this template. It covers the project's conventions, how to design Nostr events, and its security model: private keys live in localStorage, so any XSS can steal them.

Bigger features come as skills in .agents/skills/, which agents load when a task needs them. Several ship ready-made code in a files/ folder:

Skill For
nostr-security The full threat model, URL and CSS sanitizing
nip19-routing Filling in NIP19Page for each identifier type
note-content Rendering note text with links, mentions, media and embeds
nostr-comments NIP-22 comments on events or any external content
nostr-infinite-scroll Paginated feeds
nostr-encryption NIP-44 and NIP-04 encryption through the user's signer
nostr-relay-pools Querying or publishing to specific relays
relay-management A settings UI for the user's relay list
edit-profile A profile editing form
file-uploads Blossom uploads and NIP-94 imeta tags
nip85-stats Follower, reaction and zap counts from NIP-85 providers
nwc Lightning wallets (NWC, WebLN) and zaps
onchain-bitcoin A Bitcoin wallet derived from the user's Nostr key
ai-chat Streaming AI chat interfaces
capacitor Native iOS and Android apps
lockdown-mode What works under Apple's Lockdown Mode
plausible-analytics Plausible Analytics
theming Fonts, colors and themes
testing Writing Vitest tests with the TestApp wrapper

.mcp.json (Claude Code) and opencode.json (OpenCode) connect agents to the Nostrbook MCP server, which looks up NIPs and event kinds.

Project structure

src/
├── components/
│   ├── ui/          shadcn/ui components
│   └── auth/        login dialog and account switcher
├── contexts/        app config context
├── hooks/           Nostr, account and UI hooks
├── lib/             utilities, polyfills, default relays and Blossom servers
├── pages/           Index, NIP19Page, NotFound
├── test/            TestApp wrapper and test setup
├── App.tsx          providers
└── AppRouter.tsx    routes
eslint-rules/        the template's custom lint rules
.agents/skills/      skills for agents
AGENTS.md            agent instructions

Deploying

npm run build produces a static site in dist/ that any static host can serve. The app routes on the client, so the host has to serve index.html for unknown paths. Hosts that fall back to 404.html, such as GitHub Pages and nsite gateways, get that from the build.

Apps built with MKStack

  • Chorus: groups on Nostr with a built-in eCash wallet
  • Blobbi: digital pets that live on Nostr
  • Treasures: geocaching on Nostr

More apps made with MKStack

License

MKStack is dedicated to the public domain. To the extent possible under law, the authors have waived all copyright and related or neighboring rights to it.

S
Description
No description provided
Readme
3.2 MiB
0 Stars 1 Watchers 0 Forks
Languages
TypeScript 96.7%
CSS 1.6%
JavaScript 1.6%
HTML 0.1%