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: docs/pages/getting-started/adapters/prisma.mdx
+1-43Lines changed: 1 addition & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,54 +103,12 @@ The original database edge-runtime workaround, to split your `auth.ts` configura
103
103
At the moment, Prisma is still working on being fully compatible with edge runtimes like Vercel's. See the issue being tracked [here](https://github.com/prisma/prisma/issues/20560), and Prisma's announcement about early edge support in the `5.9.1`[changelog](https://github.com/prisma/prisma/releases/tag/5.9.0). There are two options to deal with this issue:
104
104
105
105
- Use the Prisma's [Accelerate](https://pris.ly/d/accelerate) feature
106
-
-Switch to the `jwt` session strategy
106
+
-Follow our [Edge Compatibility](/guides/edge-compatibility) page as the workaround. This uses the `jwt` session strategy and separates the `auth.ts` configuration into two files.
107
107
108
108
Using Prisma with the `jwt` session strategy and `@prisma/[email protected]` or above doesn't require any additional modifications, other than ensuring you don't do any database queries in your middleware.
109
109
110
110
Since `@prisma/[email protected]`, Prisma no longer throws about being incompatible with the edge runtime at instantiation, but at query time. Therefore, it is possible to import it in files being used in your middleware as long as you do not execute any queries in your middleware.
111
111
112
-
<Accordions>
113
-
<Accordiontitle="Using '@prisma/client' before 'v5.9.1' requires some additional workarounds">
114
-
115
-
You will need to separate your Auth.js configuration into two files and use the [lazy initialization](/reference/next-auth#lazy-initialization) feature to instantiate a second copy of Auth.js in the middleware without the adapter.
116
-
117
-
Define the `auth.config.ts` file:
118
-
119
-
```ts filename="auth.config.ts"
120
-
exportdefault {
121
-
providers: [GitHub, Google, Facebook, Twitter],
122
-
} satisfiesNextAuthConfig
123
-
```
124
-
125
-
Importandusethe`PrismaAdapter`inthe`auth.ts`file. ThisisyourmainAuth.jsconfigurationfilethatyou'll use around the rest of your application.
In the middleware file, however, import the first `auth.config` and instantiate a second instance of `NextAuth` using it as the configuration (note that the `adapter` is not used here to avoid the error).
143
-
144
-
```ts filename="middleware.ts"
145
-
importNextAuthfrom"next-auth"
146
-
importauthConfigfrom"./auth.config"
147
-
148
-
exportconst middleware =NextAuth(authConfig).auth
149
-
```
150
-
151
-
</Accordion>
152
-
</Accordions>
153
-
154
112
### Schema
155
113
156
114
You need to use at least Prisma `2.26.0`. Create a schema file at `prisma/schema.prisma` with the following models.
Copy file name to clipboardExpand all lines: docs/pages/guides/edge-compatibility.mdx
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,9 +67,9 @@ export default {
67
67
} satisfiesNextAuthConfig
68
68
```
69
69
70
-
2. Next, a separate **instantiated** Auth.js instance which imports that configuration, but also adds the adapter.
70
+
2. Next, a separate **instantiated** Auth.js instance which imports that configuration, but also adds the adapter and using `jwt` for the Session strategy:
71
71
72
-
```ts filename="auth.ts" {2, 10}
72
+
```ts filename="auth.ts" {2, 10, 11}
73
73
importNextAuthfrom"next-auth"
74
74
importauthConfigfrom"auth.config"
75
75
@@ -80,6 +80,7 @@ const prisma = new PrismaClient()
0 commit comments