This repository provides a starter template for integrating the Optimizely SDK with a React Native application using Expo.
- Node.js and npm installed
- Xcode (for iOS development) or Android Studio (for Android development)
-
Clone the Optimizely JavaScript SDK repository:
git clone https://github.com/optimizely/javascript-sdk.git
-
Navigate to the SDK directory and install dependencies:
cd javascript-sdk npm install
-
Create a tarball of the SDK:
npm pack
-
Clone this repository (if you haven't already)
-
Install the Optimizely SDK from the tarball you created:
# Path may vary depending on your directory structure npm install ../../sdk/javascript-sdk/optimizely-optimizely-sdk-5.3.4.tgz
-
Install other project dependencies:
npm install
This project already includes a basic implementation of the Optimizely SDK in the app/(tabs)/explore.tsx
file. The implementation includes:
- Creating a polling project config manager with an SDK key from environment variables
- Setting up an ODP (Optimizely Data Platform) manager
- Configuring a logger with debug level
- Initializing the Optimizely client with these configurations
- A React useEffect hook that calls
optimizely.onReady()
to initialize the SDK when the component mounts
To use this implementation, create a .env
file at the project root with your SDK key: EXPO_PUBLIC_OPTIMIZELY_SDK_KEY=your-sdk-key-here
npm run ios
npm run android
npm run web
app/
- Contains the main application screens and navigationcomponents/
- Reusable React componentsconstants/
- Application constants and theme configurationhooks/
- Custom React hooksassets/
- Images, fonts, and other static resources
If you encounter any issues with the SDK integration, please check:
- Ensure the tarball path is correct when installing the SDK
- Verify that all dependencies are properly installed
- Check the Optimizely SDK version compatibility
- Make sure your environment variables are properly set up