Skip to content

Start with the Next.js starter

A whole shop on the App Router in one command, rendered on the server, in Arabic and English, with checkout on the store's hosted checkout. Change anything; it's your code.

Next.js 16Node 22+4 min read

Create it

Terminal
$ npm create snizu-storefront@latest my-shop
$ cd my-shop
$ npm install
$ npm run dev

It asks for what it needs, or takes it as flags:

  • --keypk_…
    The store's publishable key, from the admin under Settings → API keys.
  • --nametext
    The store's name, shown in the header.
  • --apiurl
    Where the API answers. https://api.snizu.com unless you put a proxy in front of it.

It never takes a secret key: anyone can read what's in a storefront.

What you get

Home, collection, product, search, cart and account pages on the App Router, rendered on the server. Adding to the cart and signing in are server actions, so they work before scripts load; once scripts run, an add shows in a cart drawer at once. Paying happens on the store's hosted checkout.

  • app/[locale]/
    The pages. The language comes from the address, and proxy.ts sends / to the shopper's, Arabic when they have no preference.
  • lib/storefront.ts
    catalog() for what's the same for everyone, cached under tags. shopper() for a cart and account, from cookies, never cached.
  • lib/actions/
    Cart and account changes as server actions.
  • components/shop-provider.tsx, cart-drawer.tsx, add-to-cart.tsx
    One @snizu/react client for the page, a cart drawer whose changes show at once, and the product form that adds through it. They read the same cookies as the server, so the drawer and the cart page are one cart.
  • lib/i18n.ts
    Every word in both languages. Add a language here and it has a path.
  • lib/seo.ts
    Metadata, hreflang, Open Graph and product structured data, with app/sitemap.ts and app/robots.ts.
  • app/api/revalidate/
    Refreshes what changed when the store's webhooks say so.
  • components/funnel.tsx
    Tells the store what shoppers see and add, for its analytics.
  • app/globals.css
    Plain CSS with custom properties and logical properties, which is all right to left needs.

Its settings

.env.local
NEXT_PUBLIC_SNIZU_API_URL=https://api.snizu.com
NEXT_PUBLIC_SNIZU_PUBLISHABLE_KEY=pk_…
NEXT_PUBLIC_SITE_URL=http://localhost:3000
NEXT_PUBLIC_STORE_NAME=Siwa Grove
SNIZU_WEBHOOK_SECRET=
SNIZU_SECRET_KEY=
SNIZU_SHOPPER_IP_HEADER=
  • NEXT_PUBLIC_SNIZU_API_URLurlrequired
    Where the API answers.
  • NEXT_PUBLIC_SNIZU_PUBLISHABLE_KEYpk_…required
    The store's publishable key. Safe in browsers.
  • NEXT_PUBLIC_SITE_URLurl
    Your shop's own address, for sitemaps, canonical links and Open Graph.
  • NEXT_PUBLIC_STORE_NAMEtext
    The name in the header.
  • SNIZU_WEBHOOK_SECRETsecret
    The signing secret of the webhook pointed at /api/revalidate. Private.
  • SNIZU_SECRET_KEYsecret
    Optional and private: a secret key with no permissions, so each shopper gets their own allowance. Never prefix it with NEXT_PUBLIC_.
  • SNIZU_SHOPPER_IP_HEADERheader
    With SNIZU_SECRET_KEY: the one header holding the shopper's address on your host, which visitors can't set. Vercel and Netlify are known without it.

A change shows without a rebuild

Catalog reads are cached and tagged. In the admin, add a webhook pointing at https://your-shop/api/revalidate, subscribed to product.*, collection.* and inventory_level.updated, and put its signing secret in SNIZU_WEBHOOK_SECRET. The route checks the signature on the raw body, then refreshes only the tags the event names. Caching and revalidation has the details.

Pages the store moved

When a product, a collection or any other address has nothing to show, the shop asks the store whether it moved that page (Online store → URL redirects in the admin) and answers with a permanent redirect to where it lives now. Only then does it show the not-found page.

Many shoppers, one server

Every shopper's cart and account calls leave from your server, so to the API they come from one address and share its allowance. Put a secret key made with no permissions in SNIZU_SECRET_KEY: those calls then carry the shopper's own address, and each shopper gets their own allowance.

The address comes from one header only, one your host sets and a visitor can't. On Vercel and Netlify that's known. Elsewhere, name it in SNIZU_SHOPPER_IP_HEADER: cf-connecting-ip behind Cloudflare, or x-real-ip behind a proxy of yours that sets it. A header a visitor can write, like a plain x-forwarded-for, would let them name a new address on every request and get around per-shopper limits such as sign-in's. With nothing named, no address is sent: safe, just slower for a busy shop.

Deploy it

It runs anywhere Next.js does: Vercel, or npm run build && npm start on any Node 22 host. Set the same variables there, with NEXT_PUBLIC_SITE_URL as your real address.

Terminal
$ npm test
$ npm run typecheck
$ npm run build

npm test checks the webhook signature and the language handling.

Was this page helpful?

Updated 30 Nov 2026