GatesProvider
<GatesProvider> makes a client available to useFlag, useGates and useGatesStatus. It takes either the options to create a client, or a client you created yourself with createGates.
Props
| Prop | Type | Notes |
|---|---|---|
projectKey | string | The environment’s ek_… key. Project-wide pk_… keys are still accepted. |
environment | "development" | "preview" | "production" | Must match the key. |
apiUrl | string | Where the Gates API lives. Default http://localhost:8790. |
user | UserIdentity | null | Declarative identity. null means signed out. The only prop read after mount. |
client | GatesClient | A client from createGates. When set, the other options are ignored. |
storage | GatesStorage | get / set / remove. Defaults to AsyncStorage. |
runtime | RuntimeInfo | () => RuntimeInfo | Defaults to discovery from expo-application and expo-updates. |
refreshIntervalMs | number | Minimum gap between foreground-triggered refreshes. Default 60 000. |
timeoutMs | number | Network timeout per request. Default 10 000. |
telemetry | boolean | Send exposure and adoption events. Default true. |
fetch | typeof fetch | Your own fetch, for tests or polyfills. |
logger | { warn, debug? } | Where the SDK reports a degraded storage or a failed sync. Silent by default. |
sdkVersion | string | Reported on sync, for the dashboard’s benefit. |
UserIdentity is { id: string; traits?: Record<string, string | number | boolean> }.
Behaviour
- Children render at once. There is no loading gate.
- Configuration is read once, like a
QueryClient’s. ChangingprojectKeyorenvironmentafter mount has no effect; create a new client instead. useris compared by value. When it changes from one user to another the provider callsidentify; when it becomesnullafter a user, it callsreset. The initial user is passed to the client directly, so mount does not trigger an extra sync.- When you pass
client, the provider does not manage identity for the initial render; it still applies laterusertransitions.