how to use bun:sqlite without it leaking to the browser?
I'm using a Drizzle DB. how do i initialize it and use it in a route file in solid start?
7 Replies
You would use a server function
async function getFromDb() {
"use server"
// Access db
}
i have this in a file:
how do i use it only on the server?
like in a form action.
It depends where its used and it get treeshaken appropriately
i'm doing this and its leaking to the client...
use server shouldn't have the round brackets
i don't think that's the issue
You may get some guidance from this example with Prisma: https://github.com/solidjs/solid-start/tree/main/examples/with-prisma
Pay attention to how the
const db
is declared in one file (src/lib/db.ts
) and the actions with "use server"
are declared in another (src/lib/index.ts
), and then the components that use them are in yet another file. This separation is necessary to enable complete treeshaking so that the code that you only want on the server does not leak to the client.
I'm hoping there will be more thorough documentation on this, because I also find these things to be rather confusing.GitHub
solid-start/examples/with-prisma at main · solidjs/solid-start
SolidStart, the Solid app framework. Contribute to solidjs/solid-start development by creating an account on GitHub.