React Native surveys installation
- 1
Install the package
RequiredInstall the PostHog React Native library and its dependencies:
- 2
Configure PostHog
RequiredPostHog is most easily used via the
PostHogProvidercomponent. Wrap your app with the provider:App.tsx - 3
Send events
RecommendedOnce installed, PostHog will automatically start capturing events. You can also manually send events using the
usePostHoghook:Component.tsx - 4
Install surveys dependencies
RequiredOther than the PostHog SDK, Surveys requires a few additional dependencies to be installed.
- 5
Add the surveys provider
RequiredAdd
PostHogSurveyProviderto your app anywhere insidePostHogProvider. This component fetches surveys. It also acts as the root for where popover surveys are rendered.App.tsxIf you're not using the
PostHogProvider, addPostHogSurveyProviderto your app anywhere inside your app root component.App.tsxYou can also pass your
clientinstance to thePostHogSurveyProvider.App.tsx - 6
Next steps
RecommendedAfter installing the PostHog SDK, you can create your first survey.
Resource Description Creating surveys Learn how to build and customize your surveys Targeting surveys Show surveys to specific users based on properties, events, or feature flags How to create custom surveys Build advanced survey experiences with custom code Framework guides Setup guides for React, Next.js, Vue, and other frameworks More tutorials Other real-world examples and use cases You should also identify users and capture events with PostHog to control who and when to show surveys to your users.
Not all survey features are available on every SDK. See the SDK feature support matrix for a full comparison.
Supported Features
Not all survey features are available on every SDK. See the SDK feature support matrix for a full comparison.
Troubleshooting
- Update your SDK.
- Run a clean build if you experience issues.
- For surveys not shown, be sure to set up the surveys provider.
- If you have enabled surveys using feature flags, the flags are evaluated on the device once the PostHog SDK starts as early as possible. The SDK might be using the cached flags from the previous SDK start. If you have changed the flag or its condition, kill and reopen the app to force a new SDK start at least once.
- This will also happen in production, and you might experience some delay for the new flag/conditions to take effect on your users.
- Survey feature flag evaluation does not capture
$feature_flag_calledevents, so theUsagetab on the feature flag page won't show anything.