-
Notifications
You must be signed in to change notification settings - Fork 305
POC react native support #774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Just added initial iOS build proof of concept. PGLite runs on android and ios as a native C library! |
🚀 subscribed |
Fixed a bunch of bugs with the shared memory communication between react native and pglite. The basic tests in the example app seem to work properly now on both iOS and Android when setting up a new db or loading an existing one. |
The basics seem to work now, I think this is proof of concept achieved. To make it production usable there's still some todos:
|
(very) WIP react native support.
Warning: this is definitely not complete or entirely correct. It is proof-of-concept level. There is a lot of leftover verbose logging and incorrect/unused code from iterating upon this. I don't have much C/C++ experience so I used claude code to help write and debug this.
This adds a pglite-react-native package and at least the beginnings of the changes needed for pglite to run on react native. See react-native.md in the corresponding postgres-pglite PR for an overview.
So far the following works:
The following needs works:
To try it out
pnpm install
andpnpm build
(first time only)npm install
inpackages/pglite-react-native/example
npx expo run:android
inpackages/pglite-react-native/example
to start an android emulator, then ctrl+c to stop the rest./rebuild-mobile.sh
inpackages/pglite-react-native/example
to compile everything, build the mobile app, and install it on the simulatornpx expo start -c
to start dev serverThe rebuild-mobile.sh script automates a lot of the following steps, but you can do these manually if you have problems
postgres-pglite
runPLATFORM=android ABI=arm64-v8a PG_BRANCH=REL_17_5_WASM ./mobile-build/build-mobile.sh
to build pglite static libs for android. You need nix installed.packages/pglite-react-native
dopnpm install
packages/pglite-react-native/example
npm install
to install deps (first run only)npx expo run:android
to start android sim (first run only)rm -rf android
to clean generated android project (if needed)npx expo prebuild -p android --clean
to generate native android projectcd android
./gradlew assembleDebug
to build the apkadb install app/build/outputs/apk/debug/app-debug.apk
to install on devicecd ..
npx expo start -c
to start the react native dev serveradb logcat
to view android system logs for more detail.adb root
to get root adbadb shell
to open a shell on devicerun-as com.evelant.example
to run as app usercat files/pglite/runtime/initdb.stderr.log
to see backend logsrm -rf files/pglite/pgdata
to clear data for another run after a crashI hope this serves as a good starting point for robust react-native support!