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: pages/cloudflare/howtos/NextAuth.mdx
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,16 @@
1
+
import { Callout } from"nextra/components";
2
+
1
3
## [NextAuth.js](https://next-auth.js.org/)
2
4
3
5
NextAuth.js is an open-source authentication solution for Next.js applications.
4
6
5
7
### Solving a broken build
6
8
9
+
<Callout>
10
+
This section offers a solution for NextAuth.js v4. Use of v5 is currently blocked by the lack of
11
+
`createCipheriv` implementation.
12
+
</Callout>
13
+
7
14
NextAuth.js relies on [`createCipheriv`](https://nodejs.org/docs/v22.13.1/api/crypto.html#cryptocreatecipherivalgorithm-key-iv-options) from [`node:crypto`](https://nodejs.org/docs/v22.13.1/api/crypto.html).
8
15
9
16
`createCipheriv` is not currently implemented by the workerd runtime so apps using NextAuth.js with the default configuration break at build time.
@@ -28,3 +35,18 @@ Kudos to Arnav Gupta ([`@arnavgupta00`](https://github.com/arnavgupta00)) for co
28
35
You can find an example of this on his [example repository](https://github.com/arnavgupta00/deployment-cf-workers-prisma-nextauth).
29
36
30
37
Related issues: [`workers-sdk#206`](https://github.com/opennextjs/opennextjs-cloudflare/issues/206) and [`workerd#3277`](https://github.com/cloudflare/workerd/issues/3277).
38
+
39
+
### Solving issues in local dev
40
+
41
+
When trying to access Cloudflare bindings depending on your implementation, you might run into:
42
+
43
+
`ERROR: getCloudflareContext has been called without having called initOpenNextCloudflareForDev from the Next.js config file.`
44
+
45
+
You can resolve this issue, by calling `getCloudflareContext` in your `NextAuth` callback, for example like so:
0 commit comments