React SDK Implementation Recipes & Patterns
Recipes for the React SDK: HumanityProvider config, HumanityGate patterns, popup vs redirect auth, protected routes, and token storage options.
Prerequisites
npm install @humanity-org/react-sdkRecipe 1 — Wrap your app with HumanityProvider
import { HumanityProvider } from '@humanity-org/react-sdk';
function App() {
return (
<HumanityProvider
clientId={import.meta.env.VITE_HUMANITY_CLIENT_ID}
redirectUri={import.meta.env.VITE_HUMANITY_REDIRECT_URI}
environment="sandbox"
storage="memory"
>
{/* rest of your app */}
</HumanityProvider>
);
}Recipe 2 — Sign out
Recipe 3 — Protect a route with React Router
Recipe 4 — Choose a token storage strategy
Strategy
Security
Survives refresh
When to use
Last updated