# Link a store (https://docs.salla.dev/twilight/react/local-development/link-a-store)



Link a store when you want your theme to render your own products and settings instead of the demo ones.

A theme has no products of its own. It renders a **store**: products, categories, pages and settings come from Salla's API. Linking a store tells the dev server which one to ask.

## The default: a demo store [#the-default-a-demo-store]

A new theme renders **Theme Raed Demo Store**. It needs no login and has real products, so the page looks like a finished shop from the first minute. Switch to your own store when you want your own data or settings.

## Switch store with the CLI [#switch-store-with-the-cli]

```bash
salla theme dev --store            # asks which store
salla theme dev --store 123456789  # binds this id directly
```

Asking offers two choices: the demo store, or **your own demo store**. The second asks you to sign in (`salla login`) and lists the stores of your account. If you have none, run `salla store create`, then repeat the command.

The CLI writes your choice to `.env` and starts the server. If a server is already running, restart it.

## Where the store is saved [#where-the-store-is-saved]

In `.env` at the root of your theme:

```bash title=".env"
# The store your theme renders against.
VITE_STORE_DOMAIN=1510890315
```

`VITE_STORE_DOMAIN` is the store id (a store username also works). Only the dev server reads it. A published theme never has this file, because a live storefront takes its store from the address visitors type.

`.env` is git-ignored. A teammate who clones the theme gets the demo store until they run `salla theme dev --store`.

<Callout>
  Leave `VITE_TWILIGHT_URL` out of `.env` unless you need it. It overrides the Twilight SDK build with no version check, so a value copied in once goes stale silently.
</Callout>

## Switch store with the URL [#switch-store-with-the-url]

The dev server reads a numeric `storeId` query parameter, so one URL can name the store:

```text
http://localhost:5173/en?storeId=123456789
```

This is the address the CLI opens. The parameter wins over `.env`, so you can compare two stores in two tabs without touching any file. It is read on each full page load: open an address without it and the page falls back to `.env`.

<Callout type="warn">
  Only `localhost` trusts `storeId`. On a live storefront the store always comes from the host name, so the parameter does nothing there.
</Callout>

## Preview a draft of the settings [#preview-a-draft-of-the-settings]

A merchant's theme settings are versioned. To render a specific version, add `versionId` next to `storeId`. The [theme editor](https://docs.salla.dev/twilight/react/local-development/theme-editor) does this for you.

## Settings are reused for an hour [#settings-are-reused-for-an-hour]

While you develop, the dev server reuses the store's settings (the store, its theme settings, languages and currencies) for up to an hour, instead of asking Salla's API on every page load. The API limits how often one address can ask for a store's settings, and a dev server reloading pages quickly would reach that limit and show "Store is temporarily unavailable". Products, categories and everything else are fetched as before.

The bottom of the [local theme editor](https://docs.salla.dev/twilight/react/local-development/run-locally#the-local-theme-editor)'s side panel says when they were last fetched ("Last fetched 5 minutes ago"). To see a change you just made in the dashboard, press **Fetch fresh store data** there. The dev server's terminal says so the first time it reuses them. A published theme never does this: it asks for the settings on every page.

## Check it worked [#check-it-worked]

The CLI prints `Store: <name> (switch any time: salla theme dev --store)`. In the browser, the products should belong to that store. A "Store is temporarily unavailable" page means the id is wrong: see [Troubleshooting](https://docs.salla.dev/twilight/react/local-development/troubleshooting).

Next: [Theme editor](https://docs.salla.dev/twilight/react/local-development/theme-editor)
