Use this file to discover all available pages before exploring further.
This page covers the React hooks from @grainql/analytics-web, which provide remote configuration and advanced React integration. For basic analytics tracking in React, you can use @grainql/tag directly — see the React Quick Start.
Provider-managed is simpler for most cases. Use external client when you need to share the instance across multiple providers or need access outside React.
Cache-First Loading:
Hooks return cached values immediately, then fetch fresh data in the background. Your UI never waits for network requests.Automatic Updates:
Components automatically re-render when configurations change. No manual listener management.Performance Optimized:
Hooks use React’s built-in optimization (memo, useCallback) to prevent unnecessary re-renders.Type Safe:
Full TypeScript support with type inference for all hooks and props.React Patterns:
Follows React conventions with hooks, context, and functional patterns.
If you’re new to React’s Context API, here’s how it works with Grain:Context lets you share values across your component tree without passing props manually. GrainProvider creates a context with the Grain client:
// Provider at the top<GrainProvider config={{ tenantId: 'your-tenant-id' }}> <App /> {/* Can use hooks */} <Page /> {/* Can use hooks */} <Component /> {/* Can use hooks */}</GrainProvider>
Any component inside the provider can use Grain hooks, no matter how deeply nested. No prop drilling needed.