StoreOSv0.15.0
Getting Started

Environment Variables

What each env var does and how it connects your app to StoreOS.

What these variables do

Your storefront app needs two pieces of config to talk to StoreOS:

  1. Which store am I?NEXT_PUBLIC_SITE_API_TENANT
  2. 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
VariableWhat it doesExample
NEXT_PUBLIC_SITE_API_TENANTYour 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_URLYour 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.dev

What 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 fieldEnv var
tenantNEXT_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);

SDK configuration

On this page