Skip to content
Gates

Provider setup

import { GatesProvider } from "@gates/expo";

export default function Root() {
  const { user } = useAuth(); // your auth state
  return (
    <GatesProvider
      projectKey="ek_…"
      environment="production"
      apiUrl="https://gates.example.com"
      user={user && { id: user.id }}
    >
      <App />
    </GatesProvider>
  );
}

Children render at once. There is no loading gate, by design.

  • projectKey is the environment’s ek_… key from Project settings. Project-wide pk_… keys are still accepted.
  • environment must match the key. Sync and telemetry requests for a different environment are rejected.
  • apiUrl is where your Gates API lives. It defaults to http://localhost:8790, the local dev server, so set it for any build that leaves your machine.
  • user is declarative: pass a user when someone is signed in and null when nobody is. The provider calls identify and reset for you and compares by value, so an inline object is fine.

The provider reads every other prop once, when it mounts, the way a QueryClient reads its config. Only user is live. The full prop list is on GatesProvider.

Next: Read a flag.