Getting Started
Migrate to Shuttle
A comprehensive guide to migrating your existing Rust project to Shuttle
Migration checklist
Before starting your migration, check if your project meets these requirements:
✅ Supported Service Types
- HTTP web services using:
- Axum
- Actix Web
- Rocket
- Loco
- Other HTTP frameworks (via custom service)
- Discord bots
- Telegram bots
- Web services connecting to RPC nodes
- Services with scheduled tasks (cronjobs)
- Other service types (via custom Service)
⚠️ Other Considerations
- External resources can still be used by connecting to them
- Database migrations need to be handled separately
- Check that your project:
- Is compatible with the latest Rust version
- Can be built and run in a Docker container
If you’re unsure about any compatibility requirements, join our Discord community for help!
Migration Steps
Remember to install the Shuttle CLI if you haven’t yet!
1. Add Shuttle Dependencies
Add the required Shuttle dependencies to your Cargo.toml
:
2. Update Your Main Function
Common steps needed for migrating are:
- Change the main function to use
#[shuttle_runtime::main]
. - Change the return type and return the framework’s Router or config. This varies by framework, check examples for more.
- Add a
Secrets.toml
file and use#[shuttle_runtime::Secrets]
instead of loading environment variables. - Use
#[shuttle_shared_db::Postgres]
instead of manually connecting to a database.
Here is an example of what an Axum service might look like before and after migrating:
main.rs (before)
main.rs (after)
3. Add Shuttle configuration
If your app uses gitignored files, or uses static files at runtime, you need to add a Shuttle.toml
file with some file declarations.
Read more in Deployment files.
4. Testing it locally
5. Deploy
If everything is ready to launch:
The first deployment might take a few minutes as it sets up your infrastructure.