Skip to content

Commit c30e308

Browse files
authored
Merge pull request #99 from powersync-ja/react-native-supbase-eas-config
[DEMOS] chore: updated react-native-supabase-todolist demo to use expo environment variables
2 parents b89b963 + e2f9bb3 commit c30e308

File tree

17 files changed

+256
-96
lines changed

17 files changed

+256
-96
lines changed

.changeset/bright-stingrays-buy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@journeyapps/powersync-react-supabase-todolist": minor
3+
---
4+
5+
Configuration is now done via `.env`/`.env.local` files instead of directly in code. `AppConfig.ts` now references `process.env`. Updated project to have EAS build support.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Replace the credentials below with you Supabase, PowerSync and Expo project details.
1+
# Replace the credentials below with your Supabase, PowerSync and Expo project details.
22
EXPO_PUBLIC_SUPABASE_URL=https://foo.supabase.co
33
EXPO_PUBLIC_SUPABASE_ANON_KEY=foo
44
EXPO_PUBLIC_POWERSYNC_URL=https://foo.powersync.journeyapps.com
5-
EXPO_PUBLIC_EAS_PROJECT_ID=foo
5+
EXPO_PUBLIC_EAS_PROJECT_ID=foo # Optional. Only required when using EAS.

demos/react-native-supabase-group-chat/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ web-build/
1616
# Temporary files created by Metro to check the health of the file watcher
1717
.metro-health-check*
1818

19-
# .env
19+
# local env files
20+
.env*.local
21+
2022
*.ipa
2123
*.tar.gz
2224
.tamagui

demos/react-native-supabase-group-chat/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ Here are some helpful links:
1818

1919
- [PowerSync Website](https://www.powersync.com/)
2020
- [PowerSync Docs](https://docs.powersync.com/)
21-
- [PowerSync React Native Client SDK](https://github.com/journeyapps/powersync-js/tree/main/packages/powersync-sdk-react-native)
21+
- [PowerSync React Native Client SDK Reference](https://docs.powersync.com/client-sdk-references/react-native-and-expo)
2222
- [Supabase Docs](https://supabase.com/docs)
2323
- [Expo Docs](https://docs.expo.dev/)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Replace the credentials below with your Supabase, PowerSync and Expo project details.
2+
EXPO_PUBLIC_SUPABASE_URL=https://foo.supabase.co
3+
EXPO_PUBLIC_SUPABASE_ANON_KEY=foo
4+
EXPO_PUBLIC_SUPABASE_BUCKET= # Optional. Only required when syncing attachments and using Supabase Storage. See packages/powersync-attachments.
5+
EXPO_PUBLIC_POWERSYNC_URL=https://foo.powersync.journeyapps.com
6+
EXPO_PUBLIC_EAS_PROJECT_ID=foo # Optional. Only required when using EAS.

demos/react-native-supabase-todolist/.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
22

3-
# Credentials
4-
library/supabase/AppConfig.ts
5-
63
# dependencies
74
node_modules/
85

@@ -31,7 +28,6 @@ npm-debug.*
3128

3229
# local env files
3330
.env*.local
34-
.env
3531

3632
# typescript
3733
*.tsbuildinfo

demos/react-native-supabase-todolist/README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ bucket_definitions:
3636
```
3737
3838
## Configure The App
39+
Replace the necessary credentials in the [.env](./.env) file.
40+
Generally, the `.env` file is used for storing common environment variables shared across all instances of the application, while `.env.local` is for overriding or providing environment-specific configurations, particularly for local development.
41+
As `.env.local` is normally not checked into source control (this project has a git-ignore rule), you can copy `.env`, name it `.env.local`, and then configure as needed.
3942

40-
Copy the `AppConfig.template.ts` to a usable file
43+
### EAS Build configuration
44+
Take note that you will need an [Expo](https://expo.dev/) account if you want to use EAS for your builds. The Expo project ID should then also be configured in the environment file.
4145

42-
```bash
43-
cp library/supabase/AppConfig.template.ts library/supabase/AppConfig.ts
44-
```
46+
For secret/sensitive environment variables which shouldn't be checked into source control, you can configure them as EAS secrets. They can be added via either the Expo website or the EAS CLI, both are explained [here](https://docs.expo.dev/build-reference/variables/#using-secrets-in-environment-variables).
4547

46-
Insert the necessary credentials.
48+
General information on defining environment variables with Expo can be found here [here](https://docs.expo.dev/build-reference/variables/#can-eas-build-use-env-files).
4749

4850
## Run the App
4951

@@ -64,3 +66,12 @@ Run on Android
6466
```sh
6567
pnpm android
6668
```
69+
70+
71+
## Here are some helpful links:
72+
73+
- [PowerSync Website](https://www.powersync.com/)
74+
- [PowerSync Docs](https://docs.powersync.com/)
75+
- [PowerSync React Native Client SDK Reference](https://docs.powersync.com/client-sdk-references/react-native-and-expo)
76+
- [Supabase Docs](https://supabase.com/docs)
77+
- [Expo Docs](https://docs.expo.dev/)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { type ExpoConfig } from "expo/config";
2+
3+
import { config as dotenvConfig} from 'dotenv'
4+
import { resolve } from 'path'
5+
6+
// EAS doesn't load values from `.env` by default when consider the `app.config`
7+
dotenvConfig({
8+
path: resolve(__dirname, '.env')
9+
})
10+
11+
const projectId = process.env.EXPO_PUBLIC_EAS_PROJECT_ID;
12+
13+
const config: ExpoConfig = {
14+
name: 'powersync-example',
15+
slug: 'powersync-example',
16+
version: '1.0.0',
17+
orientation: 'portrait',
18+
icon: './assets/icon.png',
19+
userInterfaceStyle: 'light',
20+
scheme: 'powersync',
21+
splash: {
22+
image: './assets/splash.png',
23+
resizeMode: 'contain',
24+
backgroundColor: '#ffffff',
25+
},
26+
updates: {
27+
url: `https://u.expo.dev/${projectId}`,
28+
},
29+
assetBundlePatterns: ['**/*'],
30+
ios: {
31+
supportsTablet: true,
32+
bundleIdentifier: 'com.powersync.example',
33+
},
34+
android: {
35+
adaptiveIcon: {
36+
foregroundImage: './assets/adaptive-icon.png',
37+
backgroundColor: '#ffffff',
38+
},
39+
package: 'com.powersync.example',
40+
},
41+
web: {
42+
favicon: './assets/favicon.png',
43+
},
44+
extra: {
45+
eas: {
46+
projectId
47+
},
48+
},
49+
plugins: [
50+
'expo-router',
51+
[
52+
'expo-camera',
53+
{
54+
cameraPermission: 'Allow $(PRODUCT_NAME) to access your camera.',
55+
},
56+
],
57+
[
58+
'expo-build-properties',
59+
{
60+
ios: {
61+
deploymentTarget: '13.4',
62+
},
63+
},
64+
],
65+
'expo-secure-store',
66+
],
67+
};
68+
69+
export default config;

demos/react-native-supabase-todolist/app.json

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"cli": {
3+
"version": ">= 3.13.3",
4+
"promptToConfigurePushNotifications": false
5+
},
6+
"build": {
7+
"development": {
8+
"developmentClient": true,
9+
"distribution": "internal",
10+
"channel": "preview"
11+
},
12+
"preview": {
13+
"channel": "preview",
14+
"distribution": "internal"
15+
},
16+
"production": {
17+
"channel": "production"
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)