© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•13mo ago•
1 reply
dan—1106

SvelteKit (Vite) + D1 + Prisma Local development

I have a SvelteKit app that I'm developing with a D1 database accessed through Prisma.

I'm trying to run the Vite development server locally and have it connect to D1 locally.

My app works when deployed to workers (with experimental assets enabled), and can read/write from the D1 database via Prisma.

The code to initialize my database connection is:

import { PrismaClient } from '@prisma/client';
import { PrismaD1 } from '@prisma/adapter-d1';
import { env } from '$env/dynamic/private';

const adapter = new PrismaD1(env.DB);
const prisma = new PrismaClient({ adapter });
export default prisma;
import { PrismaClient } from '@prisma/client';
import { PrismaD1 } from '@prisma/adapter-d1';
import { env } from '$env/dynamic/private';

const adapter = new PrismaD1(env.DB);
const prisma = new PrismaClient({ adapter });
export default prisma;


Running locally, I typically run
vite dev --host
vite dev --host


Is there a way to get
vite dev
vite dev
running so that it can access a local D1 Instance provided by Wrangler?

If not, is there a way to get that running so that my local dev environment could write to a real/hosted D1 instance that I specify?

Let me know if there's other info that could be helpful
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Local development over local origin
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
3y ago
Local development secret store
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
7mo ago
Having Trouble Getting D1 to Work in Local Development with Drizzle ORM?
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
10mo ago
using dashboard for local development
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
3y ago