with-envs
v1.0.2
Published
Create a new project by running:
Readme
Getting Started
Create a new project by running:
bun create expo-app --template with-envsSetup
Create a new EAS project at Expo, and copy the project ID from your project settings.
Configure environment variables in your EAS project:
- Set
APP_ENVtodevelopment,preview, orproductionbased on the environment. - Set three
EXPO_PUBLIC_API_URLbased on the environment. (Add more envs if you need) - Add any additional required environment variables. Check
utils/environment.tsfor the full list.
- Update the following constants in
app.config.ts:- Set
EAS_PROJECT_IDto your Expo project ID. - Set
PROJECT_SLUGto your project slug. - Set
OWNERto your Expo account name.
- Set
You can find these values in your project details:
- Customize the app configuration in
app.config.ts:- Update the app name, package names, and bundle identifiers.
- Configure icons and schemes for each environment.
- Add
/androidand/iosto your.gitignore.
Development Setup
- Pull your development environment variables by running:
eas env:pull developmentThis will generate a .env.local file with the development environment variables.
Set up your development build using one of these options:
Option A: Create a development build with EAS:
eas build -p ios --profile developmentOption B: Prebuild locally:
npx expo prebuildRun the app:
npx expo run:iosDevelopment Workflow
The recommended workflow is to use a development client during development. When your changes are ready for testing:
- Create a preview build:
eas build -p ios --profile preview- Share the preview with your team or client. You can update this build remotely by running:
eas update -p ios --environment preview --channel previewDon't forget to pass the --environment flag when sending an update, this will ensure the update uses the correct env variables
Note: The same update process applies for production and development builds.
- For production releases:
- Build only:
eas build -p ios - Build and submit:
eas build -p ios --auto-submit
- Build only:
Switching Environments
- Pull the desired environment variables (e.g., "preview"):
eas env:pull previewThis will update the .env.local file with the preview environment variables.
- Prebuild the app:
npx expo prebuild- Run the app:
npx expo run:ios