Next.js Discord

Discord Forum

Drizzle ORM with Turso & Nextjs

Unanswered
Headless posted this in #help-forum
Open in Discord
I have this connection I am making with drizzle

// 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

seems related to it trying to compile readme files?
like it looks like nextjs is trying to parse the md files and everything
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
😭
also note that
I have a @xxxx/core package for npm i created that has the libsql stuff and that i import into my nextjs app
that 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
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
hmmm
ill try to downgrade
jumping down like 5 versions still gives the same results x.x
ai ai captain
@Ray Try 0.3.0
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
im not using it either
even if i disable it
i still get errors
Try init a new project?
Oh you using 14.0.3?
yeah
Could you try to update to latest?
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?
Doesnt build with that?
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
okay
thanks man
bruuuh
of course this will be a issue only im having
=/
Do you have a mdx-components.tsx in the root
let me see
nope
Could you share the repo and i will try it out later
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
@riský
i would love your help assuming this is ur github he referenced?
maybe you know something i dont?
@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)
Yeah idk why but bun made it work lmao
Oh nice
I didn't realise bun could be so good!
bun > nodejs
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)
Indeed