Usage with cloudflare workers: D1 database? #1881
-
Would it be possible to make use of the cloudflare workers D1 database? |
Beta Was this translation helpful? Give feedback.
Answered by
MrStickyPiston
Sep 18, 2025
Replies: 2 comments 3 replies
-
I don't see a reason why you couldn't |
Beta Was this translation helpful? Give feedback.
1 reply
-
Appearantly it is possible, but it is required to use the following vite module for dev: import { NitroApp } from "nitropack";
import { defineNitroPlugin } from "nitropack/dist/runtime/plugin";
export default defineNitroPlugin((nitroApp: NitroApp) => {
nitroApp.hooks.hook("request", async (event) => {
const _pkg = "wrangler"; // Bypass bundling!
const { getPlatformProxy } = (await import(
_pkg
)) as typeof import("wrangler");
const platform = await getPlatformProxy();
event.context.cf = platform["cf"];
event.context.cloudflare = {
env: platform["env"] as unknown as Env,
context: platform["ctx"],
};
});
}); |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
MrStickyPiston
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Appearantly it is possible, but it is required to use the following vite module for dev: