How do i access D1 in normal function in sveltekit app ? I don't care about a local replica for deve

How do i access D1 in normal function in sveltekit app ? I don't care about a local replica for development. I just want to be able to read and write to D1. I have got D1 defined in wrangler.toml, I was able to get example working but I am so lost how to get it working in sveltekit. This is a typical code to lucia auth: https://v3.lucia-auth.com/database/sqlite

// ~/username-and-password/src/lib/server/auth.js
import { Lucia } from "lucia"
import { D1Adapter } from "@lucia-auth/adapter-sqlite";
import { dev } from "$app/environment"

const adapter = new D1Adapter(D1, {
user: "user_info",
session: "user_session"
});

export const lucia = new Lucia(adapter, {
sessionCookie: {
attributes: {
secure: !dev
}
},
getUserAttributes: attributes => {
return {
username: attributes.username
}
}
})
Was this page helpful?