#Deploy next.js app to vercel that uses mysql2

19 messages · Page 1 of 1 (latest)

scenic python
#

I am really new to next.js but I am trying to deploy a app that has mysql2 and I keep getting this error when deploying.
Can I even use mysql2?

Im using Next.js 14, Next auth v5 and like I said mysql2

hazy chasmBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

scenic python
scenic python
#

Deploy next.js app to vercel that uses mysql2

polar monolith
scenic python
polar monolith
scenic python
#

Ok, but what do I have to change in my files I’m not understanding. Is it a config file?

polar monolith
polar monolith
#

Outside middleware, the edge runtime is opt in, so you simply remove the opt in declaration. In middleware you cannot opt out of the edge runtime so you cannot run mysql2 there

scenic python
#

I’m in mobile right now

#

This is what I have in middleware

scenic python
#

And it’s supposed to be like this no?

polar monolith
# scenic python The thing is, I’m using Next Auth V5

Next-auth cannot do anything about the database driver not being supported on the edge runtime unfortunately.

If you happen to use planetscale, you can use their serverless driver which is compatible with the edge runtime: https://github.com/planetscale/database-js.

If you don’t use planetscale, tough luck. You have to do one of these:

  1. Find a way to use the planetscale driver for databases outside planetscale. Doesn’t look like that is possible.

  2. Not use middleware at all, and implement the authentication redirection yourself in all routes.

  3. Migrate to planetscale (they don’t have a free plan) or neon (they have a free plan, but postgresql not mysql) because they have drivers supporting the edge runtime. Other database providers work too as long as they have an edge compatible way to query their databases.

scenic python
polar monolith
polar monolith