---
title: "Next.js authentication using Clerk, Drizzle ORM, and Neon"
description: "Clerk can handle authentication for a Next.js 14 App Router app while Drizzle ORM and Neon's serverless HTTP driver store non-PII data keyed by the Clerk user ID."
url: "https://swe.quest/articles/next-js-authentication-using-clerk-drizzle-orm-and-neon-0a85f87be532db48"
canonical: "https://neon.com/blog/nextjs-authentication-using-clerk-drizzle-orm-and-neon"
source: "Neon"
published: "2024-04-01"
difficulty: "medium"
kind: "How-to"
reading_minutes: 9
tags: ["identity-auth","react","postgres","typescript","serverless"]
---

# Next.js authentication using Clerk, Drizzle ORM, and Neon

A post on [Neon](https://swe.quest/sources/neon.md), published 2024-04-01, 9 min read, How-to. Original: [https://neon.com/blog/nextjs-authentication-using-clerk-drizzle-orm-and-neon](https://neon.com/blog/nextjs-authentication-using-clerk-drizzle-orm-and-neon)

## Summary

Clerk can handle authentication for a Next.js 14 App Router app while Drizzle ORM and Neon's serverless HTTP driver store non-PII data keyed by the Clerk user ID. The walkthrough defines a Drizzle schema, generates and pushes migrations with Drizzle Kit, and protects routes with Clerk's authMiddleware and ClerkProvider/UserButton. It then implements Server Actions that use currentUser() to insert and delete a per-user row. PII stays in Clerk's compliant infrastructure, and only the user ID is referenced in Postgres.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [React](https://swe.quest/tags/react.md) (Web & mobile)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)
- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)

## Prerequisites

- Next.js App Router ([easy posts on React](https://swe.quest/tags/react.md?difficulty=easy))
- TypeScript ([easy posts on TypeScript](https://swe.quest/tags/typescript.md?difficulty=easy))
- Basic SQL/Postgres ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))

## Keywords

Next.js, Clerk, Drizzle ORM, Neon, Drizzle Kit, Vercel, Server Actions

## Related posts

- [How to Build a Secure Project Management Platform with Next.js, Clerk, and Neon](https://swe.quest/articles/how-to-build-a-secure-project-management-platform-with-next-js-clerk-and-neon-a23e4da79b231f5e.md): Neon · 2025-02-22 · Medium · 29 min read · Identity & auth, React, PostgreSQL, Application security, Frontend
  A security-first tutorial for building Kozi, a collaborative project management app, using Next.js, Clerk authentication and a Neon serverless Postgres database accessed through Prisma.
- [Build Internal Tools Using Neon, StackAuth, and Vercel](https://swe.quest/articles/build-internal-tools-using-neon-stackauth-and-vercel-451a972f29aed443.md): Neon · 2025-07-08 · Medium · 3 min read · Identity & auth, PostgreSQL, Serverless, Product engineering
  An open-source Next.js template for internal tools combines Neon serverless Postgres, Stack Auth and Vercel free tiers to provide a database, API routes, authentication, role-based access control and an admin panel.
- [Auth setup with Neon, Keycloak and Koyeb](https://swe.quest/articles/auth-setup-with-neon-keycloak-and-koyeb-120106d3cf82095b.md): Neon · 2023-12-15 · Medium · 5 min read · Identity & auth, PostgreSQL, Deployment
  Keycloak can use Neon serverless Postgres as its backing store, with the Keycloak server deployed as a container on Koyeb.
- [How to build a complete Next.js app with Vercel and CockroachDB](https://swe.quest/articles/how-to-build-a-complete-next-js-app-with-vercel-and-cockroachdb-31ba89caae01e73a.md): Cockroach Labs · 2022-04-29 · Medium · 11 min read · React, Serverless, Databases, Frontend, JavaScript
  A step-by-step build of a social events app using Next.js pages, Vercel serverless API routes, and a CockroachDB free-tier cluster accessed via the Node.js pg driver.
- [Authenticating users in Astro using Neon Postgres and Lucia Auth](https://swe.quest/articles/authenticating-users-in-astro-using-neon-postgres-and-lucia-auth-235da5a83f745233.md): Neon · 2024-04-12 · Medium · 16 min read · Identity & auth, PostgreSQL, TypeScript, Frontend, Serverless
  Lucia Auth and a Neon serverless Postgres database provide cookie-based username/password authentication in an Astro app, with Vercel as the server-side rendering target.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
