FastAPI Clerk Starter

FastAPI starter with Clerk auth. Secure & scalable!

A FastAPI starting point with Clerk-backed sign-in for your API

This template wires a FastAPI service to Clerk so requests can carry a validated JWT, with user-related routes and SQLAlchemy for persistence. The default database is SQLite, with a path to swap in something else; interactive API docs ship with the app as described in the repository.

When it is useful

You are standing up a Python API and want hosted auth (Clerk) instead of hand-rolling login, you need a small pattern for protected handlers and user records, or you are onboarding a team to FastAPI plus a mainstream identity provider. It is a developer starter, not a finished product with billing or admin UX.

What you can do

  • Create and look up users via the documented endpoints, using a Clerk-issued token as described in the README.
  • Rely on the included JWT validation and route protection pattern rather than inventing token parsing from scratch.
  • Configure Clerk keys and database URL from the project’s environment template, manage dependencies with the documented uv workflow, and extend routes or models from there.

Limits

  • You still need a Clerk project, correct environment values, and your own deployment and HTTPS story; the repo does not replace security review or threat modeling.
  • Features are narrow by design (auth + user plumbing); multi-tenant dashboards, roles, and compliance workflows are out of scope unless you build them.

Frequently asked questions

What does this FastAPI Clerk starter include?

A FastAPI service wired to Clerk JWT validation, SQLAlchemy persistence (SQLite by default, swappable), CORS, Swagger UI, and user routes such as POST /user/create and GET /user/me that require a Clerk JWT.

How are dependencies managed?

The repository documents a uv workflow (uv venv, uv sync, optional uv add). Python 3.12+ and a Clerk account/project are prerequisites.

How do I send authenticated requests?

Include the Clerk JWT in the Authorization header as Bearer <token>. Configure DATABASE_URL, CLERK_JWKS_URL, and CLERK_ISSUER from .env.sample before running python main.py (docs at localhost:8001/docs).

What is out of scope?

It is developer starter plumbing, not a finished product with billing or admin UX. Multi-tenant dashboards, roles, and compliance workflows are out of scope unless you build them, and you still need HTTPS and security review.

Continue exploring