Lucia: Authentication Implementation Guide
repository·main·Indexed Apr 15, 2026
https://github.com/lucia-auth/luciaLucia is an open-source educational resource for implementing authentication and session management from scratch in JavaScript and TypeScript. It provides code examples and guides to build custom session handling tailored to specific databases, frameworks, and runtimes. Note: Lucia v3 is deprecated as of March 2025. The project focuses on broad compatibility and flexibility rather than a monolithic library. Includes implementation notes for Next.js and SvelteKit, token bucket rate limiting, and secure session cookie configuration.
What's inside lucia-auth/lucia
Lucia Project Overview and Licensing
mainTutorial: GitHub OAuth
mainTutorial: Google OAuth in Astro
mainThis guide walks through implementing Google OAuth in an Astro project using Lucia for session management and Arctic for OAuth handling.Initialize Google Provider with Arctic
mainInstall the
arcticpackage and initialize the Google provider with your credentials and redirect URI.Installation:
npm install arcticInitialization Code (
lib/auth.tsor similar):import { Google } from "arctic"; export const google = new Google( process.env.GOOGLE_CLIENT_ID, process.env.GOOGLE_CLIENT_SECRET, "http://localhost:3000/login/google/callback" );This
googleinstance is used to generate authorization URLs and validate authorization codes.Sources:
pages/tutorials/google-oauth/nextjs.md3. Setup Arctic
mainInstall the Arctic library:
npm install arcticInitialize the Google provider in your server code (e.g.,
$lib/server/oauth.ts):import { Google } from "arctic"; import { GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET } from "$env/static/private"; export const google = new Google( GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, "http://localhost:5173/login/google/callback" );Tutorial: Google OAuth in SvelteKit
main3. Setup Arctic
mainInstall the Arctic OAuth library:
npm install arcticInitialize the GitHub provider in your code (e.g.,
lib/oauth.ts):import { GitHub } from "arctic"; export const github = new GitHub( process.env.GITHUB_CLIENT_ID, process.env.GITHUB_CLIENT_SECRET, null );Tutorial: GitHub OAuth in Next.js
main3. Setup Arctic
mainInstall the Arctic OAuth library:
npm install arcticInitialize the GitHub provider in your server code (e.g.,
$lib/server/oauth.ts):import { GitHub } from "arctic"; import { GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET } from "$env/static/private"; export const github = new GitHub(GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, null);Tutorial: GitHub OAuth in SvelteKit
mainTutorial: Google OAuth
main