VercelLogotypeVercelLogotype
LoginSign Up
Back to Templates

Turso Per User Starter

Demo multi-tenancy with the Turso Platforms API

DeployView Demo
turso-platforms-thumb

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. 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. Run the following:

    cp .env.example .env
    npm install
  3. 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. 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 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. Run the following:

    turso auth api-tokens mint clerk

    Then set the API token in the .env file:

    TURSO_API_TOKEN=
  1. 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 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 Reponotrab/turso-per-user-starter
Use Cases
StarterMulti-Tenant Apps
Stack
Next.jsTailwind
Database
Turso
Auth
Clerk Auth

Related Templates

Get Started

  • Templates
  • Supported frameworks
  • Marketplace
  • Domains

Build

  • Next.js on Vercel
  • Turborepo
  • v0

Scale

  • Content delivery network
  • Fluid compute
  • CI/CD
  • Observability
  • AI GatewayNew
  • Vercel AgentNew

Secure

  • Platform security
  • Web Application Firewall
  • Bot management
  • BotID
  • SandboxNew

Resources

  • Pricing
  • Customers
  • Enterprise
  • Articles
  • Startups
  • Solution partners

Learn

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

Frameworks

  • Next.js
  • Nuxt
  • Svelte
  • Nitro
  • Turbo

SDKs

  • AI SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDK
  • Streamdown AINew

Use Cases

  • Composable commerce
  • Multi-tenant platforms
  • Web apps
  • Marketing sites
  • Platform engineers
  • Design engineers

Company

  • About
  • Careers
  • Help
  • Press
  • Legal
  • Privacy Policy

Community

  • Open source program
  • Events
  • Shipped on Vercel
  • GitHub
  • LinkedIn
  • X
  • YouTube

Loading status…

Select a display theme:
    • AI Cloud
      • v0

        Build applications with AI

      • AI SDK

        The AI Toolkit for TypeScript

      • AI Gateway

        One endpoint, all your models

      • Vercel Agent

        An agent that knows your stack

      • Sandbox

        AI workflows in live environments

    • Core Platform
      • CI/CD

        Helping teams ship 6× faster

      • Content Delivery

        Fast, scalable, and reliable

      • Fluid Compute

        Servers, in serverless form

      • Observability

        Trace every step

    • Security
      • Bot Management

        Scalable bot protection

      • BotID

        Invisible CAPTCHA

      • Platform Security

        DDoS Protection, Firewall

      • Web Application Firewall

        Granular, custom protection

    • Company
      • Customers

        Trusted by the best teams

      • Blog

        The latest posts and changes

      • Changelog

        See what shipped

      • Press

        Read the latest news

      • Events

        Join us at an event

    • Learn
      • Docs

        Vercel documentation

      • Academy

        Linear courses to level up

      • Knowledge Base

        Find help quickly

      • Community

        Join the conversation

    • Open Source
      • Next.js

        The native Next.js platform

      • Nuxt

        The progressive web framework

      • Svelte

        The web’s efficient UI framework

      • Turborepo

        Speed with Enterprise scale

    • Use Cases
      • AI Apps

        Deploy at the speed of AI

      • Composable Commerce

        Power storefronts that convert

      • Marketing Sites

        Launch campaigns fast

      • Multi-tenant Platforms

        Scale apps with one codebase

      • Web Apps

        Ship features, not infrastructure

    • Tools
      • Marketplace

        Extend and automate workflows

      • Templates

        Jumpstart app development

      • Partner Finder

        Get help from solution partners

    • Users
      • Platform Engineers

        Automate away repetition

      • Design Engineers

        Deploy for every idea

  • Enterprise
  • Pricing
Log InContact
Sign Up
Sign Up
Back to Templates
DeployView Demo

Platforms Starter Kit

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

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
v0

Build applications with AI

AI SDK

The AI Toolkit for TypeScript

AI Gateway

One endpoint, all your models

Vercel Agent

An agent that knows your stack

Sandbox

AI workflows in live environments

CI/CD

Helping teams ship 6× faster

Content Delivery

Fast, scalable, and reliable

Fluid Compute

Servers, in serverless form

Observability

Trace every step

Bot Management

Scalable bot protection

BotID

Invisible CAPTCHA

Platform Security

DDoS Protection, Firewall

Web Application Firewall

Granular, custom protection

Customers

Trusted by the best teams

Blog

The latest posts and changes

Changelog

See what shipped

Press

Read the latest news

Events

Join us at an event

Docs

Vercel documentation

Academy

Linear courses to level up

Knowledge Base

Find help quickly

Community

Join the conversation

Next.js

The native Next.js platform

Nuxt

The progressive web framework

Svelte

The web’s efficient UI framework

Turborepo

Speed with Enterprise scale

AI Apps

Deploy at the speed of AI

Composable Commerce

Power storefronts that convert

Marketing Sites

Launch campaigns fast

Multi-tenant Platforms

Scale apps with one codebase

Web Apps

Ship features, not infrastructure

Marketplace

Extend and automate workflows

Templates

Jumpstart app development

Partner Finder

Get help from solution partners

Platform Engineers

Automate away repetition

Design Engineers

Deploy for every idea