Drizzle ORM with Turso & Nextjs
Unanswered
Headless posted this in #help-forum
HeadlessOP
I have this connection I am making with drizzle
However whenever I try to build I am getting errors relating to libsql noted in the build log file
// db.js
import { drizzle } from "drizzle-orm/libsql";
import { createClient } from "@libsql/client";
export { default as PermissionInteger, MappedPermissions } from "./permissions";
import * as authSchema from "./schemas/auth";
import * as teamSchema from "./schemas/team";
import * as experienceSchema from "./schemas/experience";
import { DrizzleSQLiteAdapter } from "@lucia-auth/adapter-drizzle";
import * as roblox from "./providers/roblox";
export const connection = createClient({
url: process.env.TURSO_DB_URL!,
authToken: process.env.TURSO_AUTH_TOKEN,
});
export const providers = {
roblox,
};
export const db = drizzle(connection, {
schema: { ...authSchema, ...teamSchema, ...experienceSchema },
});
export const dbAdapter = new DrizzleSQLiteAdapter(
// @ts-ignore
db,
authSchema.session,
authSchema.user
);
export { authSchema, teamSchema, experienceSchema };However whenever I try to build I am getting errors relating to libsql noted in the build log file
78 Replies
HeadlessOP
seems related to it trying to compile readme files?
HeadlessOP
like it looks like nextjs is trying to parse the md files and everything
HeadlessOP
Anyone?
Toyger
do you have any specific webpack config changes in next.config.js
@Headless Only for SVGs
Toyger
can you show your next config? maybe you made a typo somewhere
HeadlessOP
😭
also note that
I have a
I have a
@xxxx/core package for npm i created that has the libsql stuff and that i import into my nextjs appthat shouldnt really change anything though
@Headless Click to see attachment
Toyger
try to comment your webpack config, and actually mdxRs too, it can mess with md files
HeadlessOP
I get the same error even if i comment them out
im really struggling on this lmao
nothing makes sense
Toyger
https://github.com/tursodatabase/libsql/issues/1276 looks like it's specifically libsql and nextjs issue, try to downgrade libsql versions, maybe some of them will work
HeadlessOP
ai ai captain
@Ray Try 0.3.0
HeadlessOP
failed
@Headless failed
Then should be other issues, i remember that 0.3.0 work and start having issue with 0.3.2 or 0.3.3
But i wasnt using markdown
Try init a new project?
Oh you using 14.0.3?
HeadlessOP
yeah
Could you try to update to latest?
HeadlessOP
sure
but before i do
yeah
does not work
latest nextjs build on libsql 0.3.0
with the stuff commented out
With what stuff commented out?
Mdx or the schema?
HeadlessOP
Doesnt build with that?
HeadlessOP
it doesnt build with it uncommented or commented
Hmm, I remember i have no problem with it but I cant access my computer right now
I will check it later
HeadlessOP
okay
thanks man
https://github.com/RiskyMH/Email/blob/main/package.json
He is using latest version also
He is using latest version also
Do you have a mdx-components.tsx in the root
HeadlessOP
let me see
nope
Could you share the repo and i will try it out later
HeadlessOP
well
the issue is
I have my frontend repo
and then i have a @org/core repo
the @org/repo is the repo that has the drizzle orm + libsql
my nextjs app repo pulls from that
I don't mind adding you to the private repos tho
HeadlessOP
@riský
i would love your help assuming this is ur github he referenced?
maybe you know something i dont?
HeadlessOP
@Ray interestingly
i used bun like he did
and bun seems to work (i think)
since it fully compiles.
but this is on my local machine
im not sure how i would get bun to run on vercel
@Headless the @org/repo is the repo that has the drizzle orm + libsql
I do have a monorepo usage of turso and drizzle and bun https://github.com/RiskyMH/Stats/blob/main/packages%2Fdb%2Fpackage.json (it may be slightly older tho)
HeadlessOP
Yeah idk why but bun made it work lmao
Oh nice
I didn't realise bun could be so good!
bun > nodejs
node rip
node rip
Rip (but isn't bun only being used here as package manager, so it's more rip npm or wherever was used before)
@riský Rip (but isn't bun only being used here as package manager, so it's more rip npm or wherever was used before)
we can say good bye to node when bun is 2.0 

Indeed