Set up Turso in your Axum project in minutes
Before you start, make sure you:
Retrieve database credentials
You will need an existing database to continue. If you don’t have one, create one.
Get the database URL:
Get the database authentication token:
Assign credentials to the environment variables inside .env
.
Add the libsql crate to the project
Optionally, you can add a package such as dotenvy
to help you work with .env
files:
Execute SQL
Use in an Axum handler
This example creates a shared Database
instance in the application state, which is then used in the handler to execute queries.
Set up Turso in your Axum project in minutes
Before you start, make sure you:
Retrieve database credentials
You will need an existing database to continue. If you don’t have one, create one.
Get the database URL:
Get the database authentication token:
Assign credentials to the environment variables inside .env
.
Add the libsql crate to the project
Optionally, you can add a package such as dotenvy
to help you work with .env
files:
Execute SQL
Use in an Axum handler
This example creates a shared Database
instance in the application state, which is then used in the handler to execute queries.