Getting Started
StoreOS environment variables
The environment variables that connect a storefront app to StoreOS: API URL, tenant UID, and where each value is set.
What these variables do
Your storefront app needs two pieces of config to talk to StoreOS:
- Which store am I? →
NEXT_PUBLIC_SITE_API_TENANT - What is my app's URL? →
NEXT_PUBLIC_SITE_URL
Add them to .env.local in your project root.
Required variables
NEXT_PUBLIC_SITE_URL=http://localhost:3000
NEXT_PUBLIC_SITE_API_TENANT=your-tenant-uid| Variable | What it does | Example |
|---|---|---|
NEXT_PUBLIC_SITE_API_TENANT | Your store's unique ID. Becomes the x-tenant header on every request so StoreOS returns your products and orders. | From StoreOS onboarding |
NEXT_PUBLIC_SITE_URL | Your storefront's public URL — used for redirects and canonical links. Use http://localhost:3000 while developing. | https://my-store.com |
The NEXT_PUBLIC_ prefix exposes values to the browser in Next.js. Use the same names in other frameworks with their env convention.
Optional variables
NEXT_PUBLIC_STATIC_FILE_BASE_URL=https://cdn.storeos.devWhat it does: Base URL when turning product image key fields into full CDN URLs. Defaults to StoreOS CDN if omitted.
Wire variables into the SDK
import { StoreFront } from "@storeos/storefront-client";
export const store = new StoreFront({
tenant: process.env.NEXT_PUBLIC_SITE_API_TENANT!,
});| Config field | Env var |
|---|---|
tenant | NEXT_PUBLIC_SITE_API_TENANT |
Customer sessions (your responsibility)
The SDK does not persist login state to disk. After login or verifyOtp:
const token = store.getAccessToken();
// → save to cookie, localStorage, or session store
// On next page load:
store.setAccessToken(savedToken);