Gathering detailed insights and metrics for @op-engineering/react-native-prisma
Gathering detailed insights and metrics for @op-engineering/react-native-prisma
Gathering detailed insights and metrics for @op-engineering/react-native-prisma
Gathering detailed insights and metrics for @op-engineering/react-native-prisma
npm install @op-engineering/react-native-prisma
Typescript
Module System
Min. Node Version
Node Version
NPM Version
38.3
Supply Chain
57.3
Quality
75.5
Maintenance
50
Vulnerability
88.3
License
Total Downloads
4,602
Last Day
8
Last Week
65
Last Month
327
Last Year
4,602
Minified
Minified + Gzipped
Latest Version
0.1.18
Package Id
@op-engineering/react-native-prisma@0.1.18
Unpacked Size
239.40 MB
Size
82.36 MB
File Count
81
NPM Version
10.2.3
Node Version
18.19.0
Publised On
18 Mar 2024
Cumulative downloads
Total Downloads
Last day
0%
8
Compared to previous day
Last week
-18.8%
65
Compared to previous week
Last month
-3.5%
327
Compared to previous month
Last year
0%
4,602
Compared to previous year
5
22
A Prisma engine adaptation for React Native.
yarn add --exact react-native-prisma react-native-quick-base64 react-native-url-polyfill @prisma/client@5.9.0-integration-react-native.5 @op-engineering/react-native-prisma@0.1.9
npx pod-install
For bare project you will need to modify the building process to run a couple of scripts that take care of bundling the migrations you generate inside the final app bundle.
Go into XCode
→ Build Phases
→ Bundle React Native Code and images
and modify it so that it looks like this:
1set -e 2 3WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh" 4REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh" 5PRISMA_MIGRATIONS="../node_modules/@op-engineering/react-native-prisma/copy-migrations.sh" # Add this 6 7/bin/sh -c "$WITH_ENVIRONMENT $PRISMA_MIGRATIONS $REACT_NATIVE_XCODE" # Add it to the list of running scripts
For Android you need to modify your apps app/Build.gradle
. Add the following at the top of the file.
1apply from: "../../node_modules/@op-engineering/react-native-prisma/react-native-prisma.gradle"
For expo this process is automated into prebuild. Modify your app.json
by adding the react-native-prisma plugin.
1{ 2 "expo": { 3 // ... The rest of your expo config 4 "plugins": ["@op-engineering/react-native-prisma"] 5 } 6}
This packages contains an extension to the prisma client that allows you to use reactive queries. Use at your own convinience and care since it might introduce large re-renders in your app.
1import { PrismaClient } from '@prisma/client/rn'; 2import { reactiveHooksExtension } from 'react-native-prisma'; 3 4const baseClient = new PrismaClient(); 5 6export const extendedClient = baseClient.$extends(reactiveHooksExtension);
Then in your React component you can use the hook:
1import {Text} from 'react-native'; 2import {extendedClient} from './myDbModule'; 3 4export default function App { 5 6 // Will automatically re-render the component with new data 7 const users = extendedClient.user.useFindMany(); 8 9 return ( 10 <Text>{users}</Text> 11 ) 12}
Bare in mind, for the reactive queries to work you have to use the extended client to modify the data:
1extendedClient.user.create({ ...userData });
There are several hooks you can use for your reactive queries:
1useFindMany(); 2useFindFirst(); 3useFindUnique();
It is also possible to use callbacks for this queries in case you are not using hooks, but you still want to get notified when data changes
1import { PrismaClient } from '@prisma/client/rn'; 2import { reactiveQueriesExtension } from 'react-native-prisma'; 3 4const baseClient = new PrismaClient(); 5 6export const extendedClient = baseClient.$extends(reactiveQueriesExtension);
No vulnerabilities found.
No security vulnerabilities found.