Docs / built-apps / FlowstackProvider

FlowstackProvider

provider

The root provider that wraps a built app and supplies backend config (baseUrl, tenantId, mode, appScope) to all Flowstack hooks.

import { FlowstackProvider } from 'flowstack-sdk'

Wrap your entire app in FlowstackProvider (Quick Start step 1). It supplies the backend connection config consumed by every Flowstack hook.

For built apps the critical field is appScope — it scopes all data to the app and the build pipeline fills __SITE_ID__ with the hex site_id. Built apps do NOT use workspaces; the backend creates them automatically.

Generated sites always run in mode: 'production' — auth, agent chat, and data all connect to real infrastructure at sage-api.flowstack.fun. Do not use mock mode for deployed sites. No Privy app ID, privyConfig.appId, or wallet peer deps are needed for the broker auth flow.

Signature

<FlowstackProvider config={config}>{children}</FlowstackProvider>

Parameters

ParamTypeNotesDescription
configFlowstackConfigrequiredBackend configuration object (see fields below).
config.baseUrlstringrequiredAPI base URL, e.g. 'https://sage-api.flowstack.fun'.
config.tenantIdstringOptional. For authenticated calls the backend derives the tenant from the brokered-login JWT and ignores any client-sent value, so built apps should not set it. Required only for usePublicCollection (anonymous access has no token to derive from); if missing there, that hook raises a clear error rather than using a default.
config.mode'production' | 'development' | 'mock'requiredConnection mode. Generated/built sites must use 'production' (real infrastructure at sage-api.flowstack.fun). 'mock' and 'development' are for local SDK development only — never deploy a built app with them.
config.appScopestringrequiredBuilt apps only — hex site ID that scopes all data to this app. The build pipeline auto-fills __SITE_ID__.
config.jwtSecretstringCasino platform config, e.g. 'flowstack-cdn-site'.
config.passwordSecretstringCasino platform config, e.g. 'flowstack-cdn-site'.
childrenReactNoderequiredThe app tree that consumes Flowstack hooks.

Examples

Minimal built-app wrap
import { FlowstackProvider, useFlowstack, BrokeredLoginButton } from 'flowstack-sdk';

function App() {
  return (
    <FlowstackProvider config={{
      baseUrl: 'https://sage-api.flowstack.fun',
      mode: 'production',
      appScope: '__SITE_ID__',  // Hex site ID — auto-filled by build pipeline
      // No tenantId — derived from the brokered-login JWT.
    }}>
      <AuthGate />
    </FlowstackProvider>
  );
}
Casino platform wrap
import { FlowstackProvider } from 'flowstack-sdk';

const config = {
  baseUrl: 'https://sage-api.flowstack.fun',
  tenantId: 't_6fe54402be43',
  mode: 'production',
  jwtSecret: 'flowstack-cdn-site',
  passwordSecret: 'flowstack-cdn-site',
};

export default function App({ children }) {
  return (
    <FlowstackProvider config={config}>
      {children}
    </FlowstackProvider>
  );
}
Warning`appScope` is required for built apps. It scopes all data to this app; the build pipeline fills __SITE_ID__ with the hex site_id.
NoteGenerated sites always run in production mode and connect to real infrastructure at sage-api.flowstack.fun. Do not use mock mode for deployed sites.
NoteNo privyConfig.appId or wallet peer deps (@privy-io/react-auth, wagmi, viem) are needed for the broker auth flow.
Note`tenantId` is derived from the JWT — don't set it for built apps. The backend reads the tenant from the brokered-login token and ignores any client-sent X-Tenant-ID. The only place it must be set explicitly is usePublicCollection (anonymous, no token).

See also

useFlowstack · BrokeredLoginButton · AuthGuard · useCollection · useAgent

Source: README.md#built-apps--generated-site-pattern · Also available in llms-full.txt and registry.json.