docs
TypeScript SDKReference

Providers

API reference for @urun-sh/react providers and auth bridges

API reference for the providers exported from @urun-sh/react.

Public API at a glance

NameImportDescription
UrunProvider@urun-sh/reactConfigures the app proxy
UrunErrorBoundary@urun-sh/reactCatches session/transport errors
UrunWorkOSProvider@urun-sh/react/workosWorkOS auth bridge (React)
UrunWorkOSProvider@urun-sh/react/next-workosWorkOS auth bridge (Next.js)
UrunAuthProvider@urun-sh/reactGeneric bridge with getAccessToken
UrunJwtProvider@urun-sh/reactStatic JWT (tests / customer-JWT)

For patterns and narrative, see React Providers.


UrunProvider

<UrunProvider baseUrl orgId appId authProvider>{children}</UrunProvider>

Configures the app proxy returned by useApp(). Nest it inside an auth bridge that supplies access tokens.

PropTypeRequiredDescription
baseUrlstringif jwt/orgId setBase URL of your uRun backend (e.g. https://urun.sh). Optional in self-mint mode (see below) — the token endpoint's response configures it.
orgIdstringif jwt setYour organization ID. Leave it out (with jwt) to activate self-mint mode.
appIdstringfor useApp()The deployed app useApp() resolves (optional in the prop types; useApp() throws without it). Alias of app; app wins when both are set.
appstringin self-mint modeAlias of appId. Required in self-mint mode.
authProviderstringAuth provider id, e.g. "workos"
jwtstringManual short-lived user JWT (bypasses the auth bridge and self-mint; advanced)
tokenEndpointstringself-mint mode onlyToken-exchange endpoint POSTed after mount (default /api/urun-token, the @urun-sh/next createTokenRoute() on-ramp). Expects { token, orgId, gatewayUrl? }.
errorFallbackReactNode | (error) => ReactNodeSelf-mint mode only: rendered when the token endpoint fails
eventsUrlstringLocal developer-tooling endpoint that receives structured session diagnostics (e.g. the endpoint urun demo runs); never receives tokens or function args
fallbackReactNode | (error) => ReactNodeRendered by the built-in error boundary on session/transport errors

Self-mint mode — omit both jwt and orgId and UrunProvider POSTs to tokenEndpoint after mount, reading { token, orgId, gatewayUrl? } off the response; the org is derived server-side from your URUN_API_KEY, so app code never hardcodes it. app becomes the one required prop. Passing jwt (or a non-empty orgId) keeps the explicit-JWT behavior shown below, where baseUrl/orgId are required.

import { UrunProvider } from '@urun-sh/react'
import { UrunWorkOSProvider } from '@urun-sh/react/workos'

<UrunWorkOSProvider clientId="client_...">
  <UrunProvider baseUrl="https://urun.sh" orgId="your-org-id" authProvider="workos" appId="my-app">
    {children}
  </UrunProvider>
</UrunWorkOSProvider>

UrunErrorBoundary

<UrunErrorBoundary fallback={<Fallback />}>{children}</UrunErrorBoundary>

A React error boundary that catches session and transport errors thrown inside the tree and renders a fallback instead of crashing.


Auth bridges

Each bridge supplies UrunProvider with short-lived access tokens. Pick the one matching your auth.

BridgeImportNotes
UrunWorkOSProvider@urun-sh/react/workosReads WorkOS AuthKit context; forwards refreshed access tokens
UrunWorkOSProvider@urun-sh/react/next-workosSame, for Next.js WorkOS apps
UrunAuthProvider@urun-sh/reactProvide a getAccessToken: () => string | Promise<string>
UrunJwtProvider@urun-sh/reactA static JWT, intended for tests and customer-JWT flows
import { UrunAuthProvider } from '@urun-sh/react'

<UrunAuthProvider getAccessToken={async () => tokenStore.current()}>
  <UrunProvider baseUrl="https://urun.sh" orgId="your-org-id" authProvider="workos" appId="my-app">
    {children}
  </UrunProvider>
</UrunAuthProvider>

No secrets in the browser

Bridges forward short-lived user JWTs only. Never pass a server API key or the urun_… deploy key to a browser client.

Styling

Import the package CSS when using the styled built-in components (media components, session-state components, the component registry built-ins):

import '@urun-sh/react/styles.css'

On this page