@stackverify/ui is a standalone SDK for building and hosting your own StackVerify storefront frontend.
You describe the store in store.json. The CLI validates that JSON, resolves trusted blocks, writes a lock file, and generates a React app. You can run that app with Vite, Next.js, or a plain Node server, then host it on Vercel, Render.com, or another Node host.
The seller owns the generated frontend. StackVerify owns the store data, trusted UI blocks, checkout rules, and future platform APIs.
After install, the two files you own are simple:
store.json
.env.local
store.json describes the store. .env.local holds the StackVerify keys. Everything else is generated or managed by your package manager and host.
Phase 2/3 wiring is present.
- The CLI generates Vite React, Next.js, and Node projects.
init,sync,dev, andbuilduse a real HTTP client for the additive/api/sdk/v1API.- Contract, block registry, store context, search, and checkout responses are validated with zod.
- Checkout uses a secret key on the server and sends an
Idempotency-Keyheader. - Fixtures remain available with
STACKVERIFY_FIXTURES=onor when no publishable key is present. - Generated browser code calls only same-origin API paths and never receives a secret key.
store.jsonremains the file you own. Change it, then runstackverify sync.
See PACKAGE_SPEC.md for the full architecture and API plan.
@stackverify/ui: the published npm package and thestackverifycommand.packages/cli: internal CLI source bundled into the published package.packages/adapters: internal target and host definitions bundled into the CLI.packages/runtime: internal runtime contract bundled into the CLI and copied into generated frontends.
Publish from the repository root with npm publish. The root package is public and the internal packages are private.
pnpm install
pnpm build
pnpm lint
pnpm typecheck
pnpm testThe built CLI entry is dist/bin.js.
Use the published package with:
npx @stackverify/ui init my-store --target vite-react
cd my-store
npx stackverify devstackverify init [directory] [--target vite-react|next|node]
stackverify sync [directory]
stackverify dev [directory]
stackverify build [directory]
stackverify start [directory]initcreates a project, writes the starter JSON, lock file, generated source,.env.example, and.gitignore.syncvalidatesstore.jsonand regenerates the app from it.devsyncs, then starts the target dev server.buildsyncs, then builds the target app.startchecks lock integrity, then starts the built app.
The target is stored in stackverify.lock.json. Pass --target only when running init.
my-store/
store.json
stackverify.lock.json
package.json
.env.example
.env.local
.gitignore
src/
generated/
App.tsx
context.json
runtime.ts
tokens.css
server/
platform.mjs
platform.d.mts
blocks/
api/
context.mjs
checkout.mjs
app/
page.tsx
api/stackverify/context/route.ts
api/stackverify/checkout/route.ts
server/
index.mjs
vercel.json
render.yaml
Files under src/generated/ are generated output. Edit store.json, then run stackverify sync. Do not edit generated files by hand.
Commit these files:
store.json
stackverify.lock.json
src/generated/
package.json
pnpm-lock.yaml or package-lock.json
Do not commit .env.local.
Copy the example into the generated project root:
cp .env.example .env.local.env.local should sit next to store.json.
STACKVERIFY_API_URL=https://stack-verify.com
STACKVERIFY_FIXTURES=off
STACKVERIFY_PUBLISHABLE_KEY=
STACKVERIFY_SECRET_KEY=STACKVERIFY_PUBLISHABLE_KEYstarts withsvsdk_pub_and is for read-only data.STACKVERIFY_SECRET_KEYstarts withsvsdk_sec_and is for checkout write calls.STACKVERIFY_API_URLdefaults tohttps://stack-verify.comand must be a valid http or https URL.STACKVERIFY_API_KEYis also read as a write fallback when the secret key is absent.STACKVERIFY_FIXTURES=onforces demo context and demo checkout without platform calls.
Rules:
- Put keys in
.env.locallocally. - On Vercel, Render.com, or another host, put keys in that host's environment settings.
- Never put a secret key in
store.json. - Never prefix a secret key with
NEXT_PUBLIC_orVITE_. - Never commit
.env.local. - Generated browser code only calls same-origin paths:
/api/stackverify/contextand/api/stackverify/checkout. - Server routes are the intended place for the secret key. They must never expose it to the browser.
The CLI and generated server helper read process environment values first, then fall back to .env.local. Spawned dev and build servers inherit those values.
Checkout is retried safely with an idempotency key. The generated runtime sends Idempotency-Key to the same-origin checkout route. If the checkout block does not supply one, the runtime creates one with crypto.randomUUID(). The server helper forwards it to the platform and never sends the secret key to browser code.
If fixtures mode is active, hosted commands print a short warning. The demo checkout result has a fixed order id so local retries stay predictable.
Put the store design in store.json at the generated project root.
The file is a design descriptor, not application source code. An AI assistant should write or edit this file only. The CLI turns it into React source.
Starter shape:
{
"version": 1,
"store": {
"slug": "zawadi"
},
"skin": {
"version": 1,
"tokens": {
"background": "#fff5f7",
"surface": "#ffffff",
"text": "#2a121c",
"mutedText": "#704255",
"accent": "#db2777",
"headingFont": "newsreader",
"bodyFont": "inter",
"radius": "md",
"density": "comfortable"
},
"layout": {
"sections": [
"header",
"search",
"hero",
"categories",
"featured",
"catalogue",
"about",
"footer"
],
"header": "simple",
"hero": "cover",
"categories": "circles",
"catalogue": "grid",
"productCard": "photoFirst",
"checkout": "sheet"
},
"visibility": {
"search": true,
"categories": true,
"featured": true,
"about": true,
"reportLink": true
}
},
"blocks": [
{ "id": "header.simple", "version": "1.0.0", "slot": "top", "props": {}, "data": {} },
{ "id": "search.bar", "version": "1.0.0", "slot": "top", "props": {}, "data": {} },
{ "id": "hero.cover", "version": "1.0.0", "slot": "main", "props": {}, "data": {} },
{ "id": "categories.circles", "version": "1.0.0", "slot": "main", "props": {}, "data": {} },
{ "id": "featured.grid", "version": "1.0.0", "slot": "main", "props": {}, "data": {} },
{ "id": "catalogue.grid", "version": "1.0.0", "slot": "main", "props": {}, "data": {} },
{ "id": "product.detail", "version": "1.0.0", "slot": "main", "props": {}, "data": {} },
{ "id": "about.card", "version": "1.0.0", "slot": "main", "props": {}, "data": {} },
{ "id": "footer.simple", "version": "1.0.0", "slot": "footer", "props": {}, "data": {} },
{ "id": "checkout.sheet", "version": "1.0.0", "slot": "overlay", "props": {}, "data": {} }
],
"routing": {
"home": "/",
"product": "/product/:id",
"search": "/search"
}
}versionmust be1.store.slugmust be lowercase with hyphens only, for examplezawadiordemo-kitchen.skin.versionmust be1.skin.tokenscontrols colors, fonts, radius, and density.skin.layoutselects trusted variants. It does not contain component source.skin.visibility.reportLinkmust staytrue.blocksmust use registered block ids and exact versions.slotmust be one oftop,main,aside,footer, oroverlay.propsanddataare validated plain JSON values.routingaccepts internal paths only.- Raw HTML, CSS strings, JavaScript, scripts, iframes, event handlers, external URLs, and arbitrary imports are rejected.
Registered blocks:
header.simple
search.bar
hero.cover
categories.circles
featured.grid
catalogue.grid
product.detail
about.card
footer.simple
checkout.sheet
All registered block versions are 1.0.0. If an AI needs a block that is not in this list, it should stop and ask for a new trusted block rather than inventing one.
Give the AI the existing store.json and this instruction:
Change only store.json.
Keep version 1.
Use only registered block ids and version 1.0.0.
Use plain JSON props and data.
Do not add HTML, CSS, JavaScript, scripts, iframes, external URLs, event handlers, or arbitrary imports.
Do not edit generated files, env files, package files, or the lock file.
Return the complete JSON file.
Recommended workflow:
- Create a project with
stackverify init. - Let the AI edit
store.json. - Write the AI result to
store.json. - Run
stackverify sync. - If validation fails, give the AI the exact error and ask it to fix only that JSON.
- Commit the JSON, lock file, and regenerated source.
The AI can safely change store identity, colors, fonts, section order, visibility, block order, slots, and simple props. It must not write application code. The SDK is deliberately designed so external AI output stays inside validated data over trusted templates.
This is the default target. It generates a React app with Vite and TypeScript.
stackverify init my-store --target vite-react
cd my-store
npm install
stackverify devScripts:
npm run dev
npm run build
npm startGenerated files include index.html, vite.config.ts, src/main.tsx, server/index.mjs, Vercel functions in api/, vercel.json, and render.yaml.
Use it for:
- Vercel with the generated
api/functions. - Any Node host with
npm start. - Render.com with the generated
render.yaml.
This target generates a Next.js App Router app.
stackverify init my-store --target next
cd my-store
npm install
stackverify devScripts:
npm run dev
npm run build
npm startGenerated files include app/page.tsx, app/globals.css, app/layout.tsx, and route handlers at app/api/stackverify/context/route.ts and app/api/stackverify/checkout/route.ts.
Use it for:
- Vercel.
- Render.com.
- Any host that supports a Node process and
npm start.
This target uses the Vite React frontend plus a plain Node HTTP server.
stackverify init my-store --target node
cd my-store
npm install
npm run build
PORT=3000 npm startIt does not generate Vercel function files. Use it for Render.com or any Node host where you want an explicit server process.
Use either target:
vite-reactuses generated functions inapi/andvercel.json.nextuses Next.js route handlers.
Set STACKVERIFY_PUBLISHABLE_KEY and STACKVERIFY_SECRET_KEY in the Vercel project settings. Do not add them to the repository.
Use next or node. The generated render.yaml uses:
buildCommand: npm install && npm run build
startCommand: npm start
Set the StackVerify keys in Render environment settings. Do not commit them.
Use vite-react or node.
npm install
npm run build
PORT=3000 npm startThe server listens on PORT, default 3000.
Static-only hosting is not supported because checkout needs a server route. Do not bundle the secret key into static assets.
- The browser only talks to same-origin API routes.
- The generated frontend never imports CLI code, database code, env values, admin helpers, or another store's data.
- Prices are never trusted from the frontend. The platform server recalculates them from product ids and quantities.
- Demo stores must never trigger real WhatsApp sends, M-Pesa requests, or customer emails.
- Keep generated pages light, phone first, and readable. No dark pages, glass cards, frosted panels, heavy shadows, or gradients.
- Do not change generated source by hand. Change the JSON and sync.
pnpm format
pnpm lint
pnpm typecheck
pnpm test
pnpm build