Skip to content
VercelLogotypeVercelLogotype
LoginSign Up

Turso Per User Starter

Demo multi-tenancy with the Turso Platforms API

DeployView Demo

Turso Per User Starter

A Next.js application that demonstrates how to use the Turso Platforms API to create a database per user.

Demo

The app below uses a database per user, and is powered by Turso.

https://turso-per-user-starter.vercel.app

Get Started

Deploy your own Turso powered platform in a few easy steps...

  • Create a Database

    • Once the database is created, you'll be presented with details about your database, and Connect details
    • Note down the following (you'll need these later):
      • Database name
      • Org name
      • Group Token (Create Group Token -> Create Token)
      • Platform API Token (Create Platform API Token -> Insert memorable name -> Create Token))
  • Sign up to Clerk

    • Create a new application from the dashboard
    • Note down the following (you'll need these later):
      • Public key
      • Secret key
  • Deploy with Vercel

    • Add the following environment variables (from the details you noted down earlier):
      • NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY - Clerk public key
      • CLERK_SECRET_KEY - Clerk secret key
      • TURSO_API_TOKEN - Platform API Token
      • TURSO_ORG - Org name
      • TURSO_DATABASE_NAME - Database name
      • TURSO_GROUP_AUTH_TOKEN - Group Token
    • Click Deploy and you're done!

You may optionally set up webhooks to automate the creation of databases in the background — learn more.

Local Development

Start building your Turso powered platform in a few simple steps...

  1. Clone this repository

    Begin by cloning this repository to your machine:

    git clone https://github.com/notrab/turso-per-user-starter.git
    cd turso-per-user-starter
  2. Install dependencies and initialize .env

    Run the following:

    cp .env.example .env
    npm install
  3. Create a new Turso database with Turso

    Follow the instructions to install the Turso CLI, and then run the following:

    turso db create <database-name>

    Alternatively, you can sign up on the web, and create a new database from there.

    Now update .env to include your organization, and database name:

    TURSO_ORG=
    TURSO_DATABASE_NAME=

    The TURSO_ORG can be your personal username, or the name of any organization you have with other users.

  4. Create a new group token

    Run the following:

    turso group tokens create <database-name>

    Now update .env to include the group token:

    TURSO_GROUP_AUTH_TOKEN=

    If you didn't already have one, a new group will be created for you with the name default.

  5. Run database migrations

    Run the following:

    npm run db:migrate

    If you make changes to db/schema.ts, make sure to run npm run db:generate to create the migrations, and npm run db:migrate to apply them.

  6. Create a new Turso API Token

    Run the following:

    turso auth api-tokens mint clerk

    Then set the API token in the .env file:

    TURSO_API_TOKEN=
  1. Configure Clerk

    Sign up to Clerk and create a new application.

    Add your Clerk public key and secret key to the .env file:

    NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
    CLERK_SECRET_KEY=
  2. Run the application

    Run the following:

    npm run dev

    Now open http://localhost:3000 with your browser to try out the app!

Optional: Webhook setup

You can automate the creation of databases per user in the background with webhooks.

Read the wiki for more information on how to set up webhooks with Clerk during development, and production.

Tech Stack

  • Turso for multi-tenant databases
  • Next.js for powerful full stack apps
  • Tailwind CSS for utility-first CSS
  • Drizzle for database migrations and ORM
  • Clerk for authentication
  • Vercel for hosting

Need help?

  1. Open an issue on GitHub
  2. Submit a Pull Request to improve this repo
  3. Join us on Discord
GitHub
Ownernotrab
Repositoryturso-per-user-starter
Use Cases
Starter
Multi-Tenant Apps
Stack
Next.js
Tailwind
Database
Turso
Auth
Clerk Auth

Related Templates

Platforms Starter Kit

Next.js template for building multi-tenant applications with the App Router and Redis.
Platforms Starter Kit thumbnail

B2B Multi-Tenant Starter Kit

A minimalistic B2B Next.js starter template that includes a landing page, a dashboard, authentication, multi-tenancy, and account settings.
B2B Multi-Tenant Starter Kit thumbnail

Agent Stack

  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • EveNew
  • ConnectNew

Core Platform

  • CI/CD
  • Content Delivery
  • Fluid Compute
  • Observability

Security

  • Platform Security
  • WAF
  • Bot Management
  • Bot ID

Tools

  • Vercel DropNew
  • Vercel Agent
  • Vercel PluginNew
  • Next.js
  • Domains
  • v0

Frameworks

  • Nuxt
  • SvelteKit
  • Nitro
  • Turborepo
  • Tanstack Start
  • FastAPI
  • xmcp
  • All frameworks

SDKs

  • Vercel SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDKNew
  • Queues SDKNew
  • Streamdown

Build

  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
  • Platform Engineers
  • Design Engineers

Learn

  • Docs
  • Blog
  • Changelog
  • Knowledge Base
  • Academy
  • Articles
  • Community

Explore

  • Customers
  • Marketplace
  • Templates
  • Partner Finder
  • Vercel + AWS

Company

  • About
  • Careers
  • Press
  • Events
  • Startups
  • Shipped on Vercel
  • Open Source Program
  • Enterprise
  • Pricing
  • Help

Legal & Trust

  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • DPA
  • Acceptable Use Policy
  • Legal (all documents)
  • Trust Center
  • Status

Social

  • GitHub
  • X
  • LinkedIn
  • YouTube
  • Instagram
  • VercelVercel
Agent Stack
  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • Eve
Core Platform
  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • CI/CD
Tools
  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • Domains
  • v0
Learn
  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base
Build
  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce
Explore
  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community
EnterprisePricing
Contact
Log InSign Up
Dashboard

Products

Agent Stack

  • AI SDK
  • AI Gateway
  • Sandbox
  • Workflows
  • Eve

Core Platform

  • Security
  • Content Delivery
  • Fluid Compute
  • Observability
  • CI/CD

Tools

  • Next.js
  • Vercel Agent
  • Vercel Plugin
  • Domains
  • v0
Resources

Learn

  • Docs
  • About
  • Blog
  • Changelog
  • Knowledge Base

Build

  • AI Apps
  • Web Apps
  • Marketing Sites
  • Platforms
  • Commerce

Explore

  • Customers
  • Marketplace
  • Partner Finder
  • AWS
  • Community
Enterprise
Pricing
Sign UpLog In
Contact
DeployView Demo

Loading status…

Select a display theme: