# Svelte Runtime Environment Variables — repStore() > Access runtime environment variables in Svelte with repStore() and repSecureStore(). Native readable stores with lazy SSE hot reload subscriptions. Source: https://rep-protocol.dev/frameworks/svelte/ ## Installation ```bash npm install @rep-protocol/svelte @rep-protocol/sdk ``` ## Basic usage ```svelte

API: {$apiUrl}

Analytics: {$analyticsKey ?? 'loading...'}

``` ## `repStore(key, defaultValue?)` Reads a **PUBLIC** tier variable as a Svelte `Readable`. ```typescript const value: Readable = repStore('API_URL'); const value: Readable = repStore('API_URL', 'fallback'); ``` - Synchronous initial value from the REP payload - Automatically updates when the variable changes via hot reload - **Lazy SSE:** the connection is established only when there is at least one subscriber, and closed when all subscribers unsubscribe ## `repSecureStore(key)` Reads a **SENSITIVE** tier variable as a `Readable`. ```typescript const value: Readable = repSecureStore('ANALYTICS_KEY'); ``` - Starts as `null` - Resolves to the decrypted value once the session key fetch completes - Errors are swallowed (the SDK logs them); the store stays `null` > **Caution** > > `repSecureStore` does **not** support hot reload. Changes to sensitive variables require a page reload. ## Hot reload `repStore` subscribes to the SSE stream lazily — only when there's at least one subscriber. The store value updates automatically. When the last subscriber unsubscribes, the SSE connection is closed. ## Development mode **Default values** ```typescript const apiUrl = repStore('API_URL', 'http://localhost:3000'); ``` **Mock payload** Add to your `index.html`: ```html ``` ## Requirements - Svelte >= 4 or Svelte 5 - `@rep-protocol/sdk` as a peer dependency For the full API reference, see [Svelte Adapter Reference](/reference/adapters/svelte/).