Remix experiments installation
- 1
Install the package
RequiredRemix versionThis guide is for Remix v2. For Remix v3, see our React Router v7 docs.
Install the PostHog JavaScript library using your package manager:
- 2
Configure Vite
RequiredAdd
posthog-jsandposthog-js/reacttossr.noExternalin yourvite.config.tsso they get bundled for SSR:vite.config.ts - 3
Create a provider
RequiredCreate a
provider.tsxfile in the app folder. Set up the PostHog provider to initialize after hydration:app/provider.tsx - 4
Wrap your app
RequiredImport the
PHProvidercomponent in yourapp/root.tsxfile and use it to wrap your app:app/root.tsx - 5
Implement your experiment
RequiredExperiments run on top of our feature flags. You can define which version of your code runs based on the return value of the feature flag.
For client-side experiments, use the JavaScript snippet. For server-side experiments, use the Node.js snippet:
- 6
Run your experiment
RequiredOnce you've implemented the feature flag in your code, you'll enable it for a target audience by creating a new experiment in the PostHog dashboard.
- 7
Next steps
RecommendedNow that you're running experiments, continue with the resources below to learn what else Experiments enables within the PostHog platform.
Resource Description Creating an experiment How to create an experiment in PostHog Adding experiment code How to implement experiments for all platforms Statistical significance Understanding when results are meaningful Experiment insights How to analyze your experiment data More tutorials Other real-world examples and use cases