Replies: 1 comment
-
I resolved it myself. I wanted to set up a D1 development environment locally and came across the OpenNext project during my research. OpenNext allows us to run a local D1 environment using only wrangler.toml. 'use server'
import { D1Database } from '@cloudflare/workers-types'
export const getD1Session = async () => {
if (process.env.D1) {
return process.env.D1
} else {
const { getCloudflareContext } = await import('@opennextjs/cloudflare')
return (getCloudflareContext().env as any).__D1 as D1Database
}
} Have a nice day! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello.
I develop web applications using Next.js 15 (App Router).
I have a question.
I want to use D1 and set up a Miniflare development environment.
I tried writing a simple script, but I couldn't get it to work in the Node.js runtime (not the Edge runtime).
Here is my code:
However, I encountered the following error:
I have installed @cloudflare/workerd-darwin-arm64 via workerd and confirmed that the binary file exists in node_modules.
Could you help me resolve this issue or suggest the best practice for setting up Miniflare with D1?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions