---
title: "Auth setup with Neon, Keycloak and Koyeb"
description: "Keycloak can use Neon serverless Postgres as its backing store, with the Keycloak server deployed as a container on Koyeb."
url: "https://swe.quest/articles/auth-setup-with-neon-keycloak-and-koyeb-120106d3cf82095b"
canonical: "https://neon.com/blog/auth-setup-with-neon-keycloak-and-koyeb"
source: "Neon"
published: "2023-12-15"
difficulty: "medium"
kind: "How-to"
reading_minutes: 5
tags: ["identity-auth","postgres","deployment"]
---

# Auth setup with Neon, Keycloak and Koyeb

A post on [Neon](https://swe.quest/sources/neon.md), published 2023-12-15, 5 min read, How-to. Original: [https://neon.com/blog/auth-setup-with-neon-keycloak-and-koyeb](https://neon.com/blog/auth-setup-with-neon-keycloak-and-koyeb)

## Summary

Keycloak can use Neon serverless Postgres as its backing store, with the Keycloak server deployed as a container on Koyeb. The steps are: create a dedicated keycloak database and a scoped keycloak\_admin role, then deploy Keycloak from a Koyeb template configured through KC\_DB\_URL, KC\_DB\_USERNAME, KC\_DB\_PASSWORD and KC\_HOSTNAME. After that, import a sample realm and authenticate a Next.js app through NextAuth.js over OAuth. For production, build an optimized Keycloak image, configure connection pooling, and consider Neon branching and point-in-time restore for recovering Keycloak data.

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)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)

## Prerequisites

- Basic PostgreSQL ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- OAuth/OpenID Connect basics ([easy posts on Identity & auth](https://swe.quest/tags/identity-auth.md?difficulty=easy))
- Container deployment ([easy posts on Deployment](https://swe.quest/tags/deployment.md?difficulty=easy))

## Keywords

Keycloak, Neon, Koyeb, NextAuth.js, Next.js, OpenID Connect

## Related posts

- [Next.js authentication using Clerk, Drizzle ORM, and Neon](https://swe.quest/articles/next-js-authentication-using-clerk-drizzle-orm-and-neon-0a85f87be532db48.md): Neon · 2024-04-01 · Medium · 9 min read · Identity & auth, React, PostgreSQL, TypeScript, Serverless
  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.
- [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.
- [Handling Auth in a Staging Environment](https://swe.quest/articles/handling-auth-in-a-staging-environment-18efe1e68fa29994.md): Neon · 2026-01-10 · Medium · 7 min read · Identity & auth, PostgreSQL, CI/CD, Testing
  Neon Auth stores users, sessions and OAuth data in a neon\_auth schema inside the Postgres database, so branching the database also branches auth state via copy-on-write.
- [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.
- [Inside a Kylon room, where people and agents build apps on Neon](https://swe.quest/articles/inside-a-kylon-room-where-people-and-agents-build-apps-on-neon-7c02cd9384e86f37.md): Neon · 2026-11-04 · Easy · 5 min read · PostgreSQL, AI agents, Multi-tenancy, Serverless, Schema migrations
  Kylon, a shared workspace where teams and AI agents build internal apps like CRMs and invoice trackers, maps its product directly onto Neon resources: one Neon project per workspace, one database per app, and one branch per draft.

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)
