You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-20
Original file line number
Diff line number
Diff line change
@@ -4,16 +4,37 @@ A Prisma engine adaptation for React Native. Please note that this is in [Early
4
4
5
5
## Installation
6
6
7
+
Install `@prisma/client`, `@prisma/react-native` and the `react-native-quick-base64` dependency:
8
+
7
9
```
8
10
npm i --save --save-exact @prisma/client@latest @prisma/react-native@latest react-native-quick-base64
11
+
```
12
+
13
+
To ensure migration files are copied into the app bundle you need to either enable the Expo plugin or configure ios and Android manually:
14
+
15
+
### Expo
16
+
17
+
If you are using Expo, you can add the expo plugin to automatically copy migration files. Modify your `app.json` by adding the react-native-prisma plugin:
18
+
19
+
```json
20
+
{
21
+
"expo": {
22
+
// ... The rest of your expo config
23
+
"plugins": ["@prisma/react-native"]
24
+
}
25
+
}
26
+
```
27
+
28
+
To activate the plugin, run prebuild:
29
+
30
+
```
9
31
npx expo prebuild --clean
10
32
```
11
33
12
-
### Bare React Native projects
34
+
The Expo plugin simply configures the Android and ios projects during the prebuild phase. If you are not using Expo, you can do this manually:
13
35
14
-
For bare project you will need to modify the build process to run a couple of scripts that take care of bundling the migrations you generate inside the final app bundle.
15
36
16
-
####iOS
37
+
### iOS
17
38
18
39
Go into `Xcode` → `Build Phases` → `Bundle React Native Code and images` and modify it so that it looks like this:
19
40
@@ -29,30 +50,17 @@ PRISMA_MIGRATIONS="../node_modules/@prisma/react-native/copy-migrations.sh" # Ad
29
50
/bin/sh -c "$WITH_ENVIRONMENT$PRISMA_MIGRATIONS$REACT_NATIVE_XCODE"# Add it to the list of running scripts
30
51
```
31
52
32
-
####Android
53
+
### Android
33
54
34
55
For Android you need to modify your apps `app/Build.gradle`. Add the following at the top of the file.
For expo this process is automated into prebuild. Modify your `app.json` by adding the react-native-prisma plugin.
43
-
44
-
```json
45
-
{
46
-
"expo": {
47
-
// ... The rest of your expo config
48
-
"plugins": ["@prisma/react-native"]
49
-
}
50
-
}
51
-
```
52
-
53
61
## Enable React Native support in your schema file
54
62
55
-
React Native support is currently a preview feature and has to be activated in your schema.prisma file:
63
+
React Native support is currently a preview feature and has to be activated in your schema.prisma file. You can place this file in the root of the application:
56
64
57
65
```ts
58
66
generatorclient {
@@ -73,6 +81,13 @@ model User {
73
81
}
74
82
```
75
83
84
+
You can create the database file and initial migration using Prisma migrate:
85
+
86
+
```
87
+
npx prisma@latest migrate dev
88
+
```
89
+
90
+
76
91
you can now generate the Prisma Client like this:
77
92
78
93
```
@@ -144,11 +159,11 @@ On application start you need to run the migrations to make sure the database is
0 commit comments