Getting started
This guide takes you from an empty folder to a storefront that sends shoppers to the Sevigram-hosted checkout. You start against the public demo shop, so you don’t need a Sevigram account until you connect your own shop.
Requirements
Section titled “Requirements”- Node 26 or newer, with the npm that ships with it. Check with
node --version. - A terminal, and a browser on the same machine.
- To connect your own shop later: a Sevigram business with access to custom storefronts. See Access.
Create a project
Section titled “Create a project”npm create @sevigram/loom@latest my-shopcd my-shopThis creates my-shop/, a React Router 7 app with server rendering. It installs the dependencies and writes a .env file that points at the Sevigram demo shop:
Using the Sevigram demo shop (read only). Replace SEVIGRAM_STOREFRONT_TOKEN in .env with your own token to connect your shop.Options go after --, for example npm create @sevigram/loom@latest my-shop -- --token sfpub_…:
| Option | What it does |
|---|---|
[directory] |
Where to create the app. It must be empty or not exist yet. |
--token <sfpub_…> |
Use your own public token instead of the demo shop’s. |
--private-token <sfprv_…> |
Also write your private token to .env, for server use only. |
--api <baseUrl> |
A different Storefront API base URL. You normally never need it. |
--no-install |
Skip npm install; run it yourself later. |
Run against the demo shop
Section titled “Run against the demo shop”npm run checknpm run devnpm run check runs loom check, which checks each setting in .env:
OK Public token prefix: token sfpub_abcd… has the sfpub_ prefixOK API version: base URL targets /v1OK Public token: accepted for origin http://localhost:5173OK Connected to the Sevigram demo shop (read only). Checkout and contact are turned off; add your own token to connect your shop.npm run dev starts the development server on http://localhost:5173. You see the demo shop’s home page, products, collections, services with bookable times, and reviews, with a banner saying you’re browsing the demo.
The demo shop is read only. You can browse, choose variants, pick booking times and fill the cart, but Checkout and the contact form are turned off.
The demo token only works from these origins:
http://localhost:5173andhttp://127.0.0.1:5173, fornpm run devandnpm run preview;http://localhost:3000andhttp://127.0.0.1:3000, fornpm start.
APP_ORIGIN in .env must be the address in your browser’s address bar, and one of those four.
If Sevigram issues a new demo token, existing demo projects stop working. Create a new project to get the current token, or connect your own shop.
Connect your shop
Section titled “Connect your shop”-
In the Sevigram business app, open Settings → Custom storefronts and create a storefront.
-
Add its allowed origins. For local development, add
http://localhost:5173. For production, add your site’s origin, for examplehttps://shop.example. -
Copy the public token, and optionally the private token, which is shown only once. See Authentication.
-
Edit
.env:Terminal window # Replace the demo token with yours.SEVIGRAM_STOREFRONT_TOKEN=sfpub_…# Optional, server only. Needed for customer accounts.SEVIGRAM_STOREFRONT_PRIVATE_TOKEN=sfprv_…APP_ORIGIN=http://localhost:5173You can delete
SEVIGRAM_DEMO_TOKENandSEVIGRAM_DEMO_ORIGINS. They only describe the demo shop. -
Run the checks and start the app again:
Terminal window npm run checknpm run devThe demo banner is gone, and Checkout and the contact form work.
Public or private token? The public token goes to the browser for the cart, availability and checkout, and only works from the allowed origins. The private token is used only in server code, through @sevigram/loom/server. With it, server-rendered pages skip the origin check and can forward each shopper’s IP for rate limiting. Never put it in browser code, a VITE_ variable, a commit or a log.
Take a shopper to checkout
Section titled “Take a shopper to checkout”The starter already does all of this. Here’s what happens, so you can test it and change it.
- Browse. Pages load the shop, products, collections and services on the server.
- Add to the cart. A product page adds the chosen variant with
AddToCartButton. A service page adds a booking time picked inBookingCalendar. The cart lives in the shopper’s browser, one per storefront. - Check out. On
/cart,CheckoutButtonsends the cart toPOST /checkouts. Sevigram prices every line on its side and returns a session with acheckout_url, and the button redirects the shopper there. - Pay on Sevigram. The hosted checkout collects the shopper’s details and payment. A session expires after 30 minutes and reserves no stock until it’s paid.
- Come back. Sevigram sends the shopper to
APP_ORIGIN/orders/return. The starter stores the order token, removes it from the address bar and shows the order at/orders/<id>. A shopper who abandons checkout and selects “Return to store” lands on the cart, still intact.
Each checkout you finish is a real order in your business.
In your own components, the same flow is:
import { AddToCartButton, CheckoutButton, useCart } from "@sevigram/loom";
export function BuyBox({ variantId, appOrigin }: { variantId: string; appOrigin: string }) { const { count } = useCart(); return ( <> <AddToCartButton line={{ type: "product", variantId, quantity: 1, fulfillment: { method: "delivery" } }} /> <CheckoutButton returnUrl={`${appOrigin}/orders/return`} onConflict={(error) => console.warn(error.lines)} > Checkout ({count}) </CheckoutButton> </> );}See Components and hooks for every prop.
Customer accounts
Section titled “Customer accounts”Customers can sign in to see their orders, bookings, quotes, invoices and deliverables, and to check out as themselves. In the starter, Sign in in the header goes to /account/sign-in, where the shopper enters their email and the one-time code Sevigram sends.
You need:
SEVIGRAM_STOREFRONT_PRIVATE_TOKENon your server. Without it, the Sign in link is hidden.APP_ORIGINequal to the exact public origin shoppers use. Sign-in, sign-out and signed-in checkout compare it with the request’sOriginand answer403when they differ, so a shop opened athttps://www.shop.examplewithAPP_ORIGIN=https://shop.examplecan’t sign in.
The session token lives only in an HttpOnly cookie, __Host-sevigram_customer. It never reaches page data, browser storage or a URL. Signed-in checkout is created on your server with the private token, so the order belongs to the customer.
On the demo shop, sign in as [email protected] with the code shown on screen.
- The starter: its pages, settings and scripts.
- Deploying: run it in production.
- Requests and errors: every error code and what to do.