Menu

Add Clerk Authentication to a Next.js App Router Project
📰

Add Clerk Authentication to a Next.js App Router Project

DEV Community: nextjs·Gaurav Guha·15 days ago
#yCrjm6uP
#devtonextjs#devto#dev#clerk#user
Reading 0:00
15s threshold

The Problem

You need production-ready authentication in a Next.js App Router project without spending weeks building login flows, OAuth providers, 2FA, and session management from scratch.

Step 1: Create the Clerk Application

Sign up at clerk.com and create an application. Pick the providers you want enabled at creation (email, Google, GitHub are the standard set). You can add more later.

Grab two values from the dashboard:

NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY : safe for the browser

CLERK_SECRET_KEY : server-side only

Step 2: Install the SDK

npm install @clerk/nextjs

Enter fullscreen mode

Exit fullscreen mode

Add to .env.local :

NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY = pk_test_... CLERK_SECRET_KEY = sk_test_...…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.