Not able to connect my hyperdrive to my

Not able to connect my hyperdrive to my existing Neon DB with Drizzle ORM. WHY? error when running pnpm run dev my wrangler.toml [[hyperdrive]] binding = "HYPERDRIVE" id = "<ID>" i got the ID by running npx wrangler hyperdrive create linkp-neon-hyperdrive --connection-string=" output: šŸš§ Creating 'linkp-neon-hyperdrive' āœ… Created new Hyperdrive config { "id": "<ID>", "name": "linkp-neon-hyperdrive", "origin": { "host": "ep-old-sky--pooler.ap-southeast-1.aws.neon.tech", "port": 5432, "database": "linkp-db", "scheme": "postgresql", "user": "hyperdrive-user" }, "caching": { "disabled": false } } Then in my src/index.ts i have created a middlware to attach my DB instance in my requests: export const injectDB = createMiddleware(async (c, next) => { try { console.log( Connecting to database...${c.env.HYPERDRIVE.connectionString} ); const sql = neon(c.env.HYPERDRIVE.connectionString); c.req.db = drizzle({ client: sql, schema }); await next(); } catch (error) { console.error("Database connection error:", error); throw new HTTPException(503, { message: "Database connection failed" }); } }); while drizzle is coming from import { drizzle } from "drizzle-orm/neon-http"; How can i solve this issue? also tried using Postgres & node-postgres instead of neon-http
No description
4 Replies
thomasgauvin
thomasgauvinā€¢3w ago
The error message screenshot that you shared was related to local development. Local development with npx wrangler dev will be using not the Hyperdrive configuration (in Cloudflare) but instead connect directly to a local database using the localConnectionString parameter. Full details in https://developers.cloudflare.com/hyperdrive/configuration/local-development/ If you want to use the 'remote' Hyperdrive configuration in Cloudflare, you can run npx wrangler dev --remote
Sandip
Sandipā€¢3w ago
getting some error while running this command
npx wrangler dev --remote
npx wrangler dev --remote
thomasgauvin
thomasgauvinā€¢3w ago
We're going to be removing that warning, but for now, if you add a localConnectionString in your wrangler.toml like this, when you run npx wrangler dev --remote, it will use the remote resource.
No description
Sandip
Sandipā€¢3w ago
thanks @thomasgauvin will try it out getting this error
Uncaught ReferenceError: document is not defined\
Uncaught ReferenceError: document is not defined\
Note: m using supabase client with remix

Did you find this page helpful?