Fullstack Templates
SaaS Starter Template
We’ve created a SaaS template that you can use to get started quickly with a fullstack Rust + Next.js app.
The design of the template is based on a sales-oriented Customer Relationship Management (CRM) tool where users will be able to view their customers, sales records as well as some analytics.
Features
- Take subscription payments with Stripe
- Email session-based login
- Mailgun (email subscription, welcome email etc)
- Pre-configured frontend routes for easy transition
- Examples of how to implement simple dashboard analytics
Pre-requisites
- Rust
- Node.js/NPM.
- Typescript.
- cargo-shuttle
Getting Started
-
Initialize the template with:
-
cd into the folder
-
Run
npm i
to install the dependencies on the frontend. -
Set your secrets in the Secrets.toml file at the
Cargo.toml
level of your backend folder. Unset secrets will default to “None” to prevent automatic crashing of the web service, but some services may not work.
Development Scripts
- Using
dev
for Development:- Run
npm run dev
to start your application with live reload capabilities. This script usesturbowatch
to monitor changes in both the frontend and backend. - Visit http://localhost:8000 once the app has built.
- If you prefer using
cargo-watch
instead ofturbowatch
, the watch feature can be disabled in theturbowatch.ts
file.
- Run
- Frontend-Focused Development with
next-dev
:- For a frontend-specific development workflow, use
npm run next-dev
. - This script runs Next.js in a development mode optimized for faster builds and reloads, enhancing your frontend development experience.
- For a frontend-specific development workflow, use
- Analyzing Bundle Size with
analyze
:- The
analyze
script is designed to provide insights into the bundle size of your Next.js application. - Run
npm run analyze
to generate a detailed report of the size of each component and dependency in your bundle. - This is particularly useful for identifying large dependencies or components that could be optimized for better performance.
- The
Troubleshooting
- If you change the migrations after running locally or deploying, you will need to go into the database itself and delete the tables. You can do this easily with something like psql or pgAdmin.
- If connecting to external services like Stripe doesn’t work, try checking your Secrets.toml file.
- Shuttle connects by default to port 8000 - if you’re currently already using something at port 8000, you can add
the
--port <port-number>
to thecargo shuttle run
command to change this.
Was this page helpful?