This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk-react / EnginexProviderProps

EnginexProviderProps ​

Properties of EnginexProvider.

Properties ​

children? ​

optional children?: ReactNode

App tree.


client ​

client: EnginexClient

Core client (createEnginexClient). Create it once, outside the React tree, and reuse it.


initialSession? ​

optional initialSession?: Session

Session used by useSession in the server render and during hydration. Default: anonymous (the server never reads the app's store, so the client's first render is also anonymous and there is no hydration error). Pass it only when the server really knows the session, e.g. a TokenStore in a cookie read with cookies() in authenticated SSR: the server and the hydration render the same session and do not flash as anonymous. It must be the same on both sides and is read only on mount (changing the prop later is ignored); after hydration useSession goes back to reading client.session. It changes neither the client's session nor the cache.

It applies only to what depends only on the session (header, menu). The query factories build the key from client.session, not from it, and on SSR the browser client has no session: a component that renders a user query on the server uses the 'anonymous' key and hydration fails. Do not wrap components that render user queries on SSR with an authenticated initialSession: gate them on the authenticated useSession() with the anonymous default (they mount right after hydration and use the hydrated data without a request), or render the player's data in a Server Component.


queryClient? ​

optional queryClient?: QueryClient

The app's QueryClient (used as given, nothing changed). Without it, the provider creates one per instance (never a module singleton, so SSR does not share a cache between requests), with a staleTime of 60 s on queries: data hydrated from the server (prefetchEnginex) is not fetched again right on mount. The staleTime does not travel in the dehydrated state; the browser QueryClient's is always the one that decides. In your own QueryClient, use a staleTime above zero for the same reason.