> ## Documentation Index
> Fetch the complete documentation index at: https://docs.westyx.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# React SDK - Design decisions

> Why the React SDK accepts only public keys, compiles its client in, runs only in the browser, and re-reads values on render.

## Public keys only

A browser SDK ships inside a bundle any visitor can read, so it accepts only a public key (`wxp_`).
Public keys cannot read secrets, and the backend's Double-Gate check ties them to one service host.
No configuration makes a secret key work here, and that is deliberate.

## The browser client is compiled in, not installed

The client - cache, sync, live stream, error mapping - is written once and shared with the Angular and
Vue SDKs, and compiled into this package. You install one package: there is no second dependency to
resolve and no extra registry to configure, and the three SDKs cannot drift into different behaviour.

## Client-only

`NexusProvider` creates its client in an effect, which browsers run and a server render does not. A
server render therefore produces `loadingFallback` and nothing else: no sync, no read, no connection.
The tree mounts for real after hydration. The build is marked `'use client'`, so a React Server
Component may import the provider and render it as a client boundary. Server code reads flags,
configs and secrets with a backend SDK - see
[the server side](https://docs.westyx.dev/sdks/react/getting-started.md#the-server-side-secrets-in-a-route-handler).

## Values are re-read on render

`useSyncExternalStore`'s `getSnapshot` re-reads the client rather than returning a cached snapshot,
and a read is what participates in the cache's TTL: a render past the TTL starts a background
refresh, with the request rate bounded by the TTL and by the client's in-flight coalescing. While the
live stream is unavailable the client also reads its own cache once per TTL, so an idle page keeps
refreshing without a render to drive it; the hooks re-render when that refresh changes something. A composite value's identity is held across a sync that changed nothing, so an unchanged
object does not re-render its consumers.

## Tested framework versions

React 18 and 19, each type-checked as well as tested in CI: a type that breaks only on the older major
is invisible to a test runner that strips types.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.