SDK Overview
SkyState ships JavaScript/TypeScript SDKs for public state, user state, and hosted end-user auth. See what public state is for.
| Package | Description |
|---|---|
@skystate/core | Framework-agnostic client library. Use this for any JavaScript runtime - Node.js, Vanilla JS, or when building your own framework integration. |
@skystate/react | React bindings built on @skystate/core. Provides a context provider and hooks for public state, user state, and hosted auth. |
Supported Platforms
Both packages run in modern browsers and Node.js.
- Browser: Vite, webpack, Rollup, esbuild, or any bundler that supports ESM
- Node.js: Uses the built-in
fetchAPI - Framework support: The core package is framework-agnostic.
Contract
| Contract | Detail |
|---|---|
| Provider scope | One mounted provider maps to one account, project, and environment. Remount to switch scope. |
| Keyed hook return shapes | Keyed public hooks return { value }; keyed user hooks return { value, set, clear, syncStatus, draft }. See React SDK hooks. |
| Health | useStatus().health reports overall loading/error status. See useStatus. |
| Metadata | SDK accessors return application values and subsystem status only. Use the console, CLI, or REST API for inspection, audit, or history metadata. See Value-Only Metadata Contract. |
| Public reads are available before login | Public state can render for signed-out visitors. See Public state, usePublicState, and client.publicState.get(). |
| User state requires login | User state loads and writes require an authenticated end-user session. Call useStatus().auth.loginWithRedirect() to start the login flow. See useUserState, User State, and Auth. |
| Public-state cache TTL | Public-state reads are cached longer in production than in development or staging. See Caching for the concrete TTLs. |
| Fixed environments | Environments are fixed slugs. See Environments. |
| Account/project route identifiers | SDK clients must use the current account route identifier and project identifier; route changes break URLs. See Accounts. |
Installation
See Installation - SDKs for how to install either package.
Sections
@skystate/core
Framework-agnostic client. Covers createSkyStateClient, public state, and user state.
- Client reference: initialization, reading values, subscribing to changes
- Environments: how environment slugs work
@skystate/react
React bindings. Covers the provider, hooks, and TypeScript patterns.
- SkyStateProvider: context provider props and setup
- useStatus: auth and health: auth state, auth actions, and unified operational health
- usePublicState: read public state keys
- useUserState: read, write, and draft user state
- Error Handling: write-result contract, error codes, retry policy