DEV Community

Cover image for Next-Auth is hell
Ihor Filippov
Ihor Filippov

Posted on

Next-Auth is hell

Today, I want to talk a bit about Next.js.

Probably one of the best decisions I've made recently was switching to it. It's genuinely a powerful tool for solo founders. You don't need to write a separate API and worry about SEO optimization - Next.js does it for you. I'm sure there are some hacks to make it even better, but what's available by default in this direction looks quite impressive. For example, a page with an editor, which is inherently heavy, has pretty good metrics in PSI, although I didn't do anything special for it.

However, there are some problematic areas. For instance, authentication. Many people complain that the examples in the official documentation provide very scant information on how to make a working auth system.

Next.js, by default, promotes the use of next-auth. But the community, to put it mildly, is not satisfied with this tool. For example, setting up an auth with a session that will be stored in the DB requires incredible hacks and suffering.

So, I've identified a few other options to handle this situation.

  • Custom approach. I found this snippet on the internet, it might be useful for someone.
  • Lucia Auth. Many people on Reddit speak very positively about this tool, and I'll likely work with it.
  • Clerk. Essentially, it's a SaaS that takes all the burdens of authentication. It seems like a cool thing for small projects, but I haven't tried it, so it's hard to say.

Honestly, I'm still hesitating between options 2 and 3.

What do you use for user authentication in your project?

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more