Skip to content

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.

  • 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.
Terminal window
npm create @sevigram/loom@latest my-shop
cd my-shop

This 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.
Terminal window
npm run check
npm run dev

npm run check runs loom check, which checks each setting in .env:

OK Public token prefix: token sfpub_abcd… has the sfpub_ prefix
OK API version: base URL targets /v1
OK Public token: accepted for origin http://localhost:5173
OK 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:5173 and http://127.0.0.1:5173, for npm run dev and npm run preview;
  • http://localhost:3000 and http://127.0.0.1:3000, for npm 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.

  1. In the Sevigram business app, open Settings → Custom storefronts and create a storefront.

  2. Add its allowed origins. For local development, add http://localhost:5173. For production, add your site’s origin, for example https://shop.example.

  3. Copy the public token, and optionally the private token, which is shown only once. See Authentication.

  4. 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:5173

    You can delete SEVIGRAM_DEMO_TOKEN and SEVIGRAM_DEMO_ORIGINS. They only describe the demo shop.

  5. Run the checks and start the app again:

    Terminal window
    npm run check
    npm run dev

    The 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.

The starter already does all of this. Here’s what happens, so you can test it and change it.

  1. Browse. Pages load the shop, products, collections and services on the server.
  2. Add to the cart. A product page adds the chosen variant with AddToCartButton. A service page adds a booking time picked in BookingCalendar. The cart lives in the shopper’s browser, one per storefront.
  3. Check out. On /cart, CheckoutButton sends the cart to POST /checkouts. Sevigram prices every line on its side and returns a session with a checkout_url, and the button redirects the shopper there.
  4. 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.
  5. 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.

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_TOKEN on your server. Without it, the Sign in link is hidden.
  • APP_ORIGIN equal to the exact public origin shoppers use. Sign-in, sign-out and signed-in checkout compare it with the request’s Origin and answer 403 when they differ, so a shop opened at https://www.shop.example with APP_ORIGIN=https://shop.example can’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.