How to connect to local sqlite database

I wanted to play around with drizzle and sqlite in a next.js project. But I can’t even create the client like it’s described in the docs:
// page.tsx
import { drizzle } from "drizzle-orm/connect";

const getData = async () => {
const db = await drizzle("libsql", "file:local.db");
};

export default async function Home() {
return <div>Hello</div>;
}
// page.tsx
import { drizzle } from "drizzle-orm/connect";

const getData = async () => {
const db = await drizzle("libsql", "file:local.db");
};

export default async function Home() {
return <div>Hello</div>;
}
I get the following error: Module build failed: UnhandledSchemeError: Reading from "bun:sqlite" is not handled by plugins (Unhandled scheme). Webpack supports "data:" and "file:" URIs by default. You may need an additional plugin to handle "bun:" URIs. What am I doing wrong here and how can I fix this? It’s very confusing because I’m not even trying to use bun. Thank you!
2 Replies
Mozzy
Mozzy2mo ago
Had the same issue while trying the new connection method: https://discord.com/channels/1043890932593987624/1043890932593987627/1293003908192538668 In short, don't use the new simplified connection method with Next.js
wolf/gang
wolf/gangOP2mo ago
Thank you! I just got it running with the synchronous method like described in the docs:
// page.tsx
import { drizzle } from "drizzle-orm/libsql";
import { createClient } from "@libsql/client";

const getData = async () => {
const client = createClient({ url: "file:local.db" });
const db = drizzle(client);
};

export default async function Home() {
return <div>Hello</div>;
}
// page.tsx
import { drizzle } from "drizzle-orm/libsql";
import { createClient } from "@libsql/client";

const getData = async () => {
const client = createClient({ url: "file:local.db" });
const db = drizzle(client);
};

export default async function Home() {
return <div>Hello</div>;
}
Want results from more Discord servers?
Add your server