
A Next.js application that demonstrates how to use the Turso Platforms API to create a database per user.
The app below uses a database per user, and is powered by Turso.
https://turso-per-user-starter.vercel.app
Deploy your own Turso powered platform in a few easy steps...
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY - Clerk public keyCLERK_SECRET_KEY - Clerk secret keyTURSO_API_TOKEN - Platform API TokenTURSO_ORG - Org nameTURSO_DATABASE_NAME - Database nameTURSO_GROUP_AUTH_TOKEN - Group TokenYou may optionally set up webhooks to automate the creation of databases in the background — learn more.
Start building your Turso powered platform in a few simple steps...
Begin by cloning this repository to your machine:
Run the following:
Follow the instructions to install the Turso CLI, and then run the following:
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:
The
TURSO_ORGcan be your personal username, or the name of any organization you have with other users.
Run the following:
Now update .env to include the group token:
If you didn't already have one, a new group will be created for you with the name
default.
Run the following:
If you make changes to
db/schema.ts, make sure to runnpm run db:generateto create the migrations, andnpm run db:migrateto apply them.
Run the following:
Then set the API token in the .env file:
Sign up to Clerk and create a new application.
Add your Clerk public key and secret key to the .env file:
Run the following:
Now open http://localhost:3000 with your browser to try out the app!
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.