title | banner | ||
---|---|---|---|
Getting Started |
|
import VideoPlayer from '../../../components/VideoPlayer.astro';
This guide will help you get your new SaaS app up and running.
If you prefer video tutorials, you can watch this walkthrough below which will guide you through most of the setup (installation, authentication, payments, etc.). If you get stuck at any point, you can refer back to these docs for more information.
You must have Node.js (and NPM) installed on your machine and available in PATH
to use Wasp.
Your version of Node.js must be >= 18.
To switch easily between Node.js versions, we recommend using nvm.
:::note[Installing and using nvm]
Need help with nvm?
Then, install a version of Node.js that you need:
```shell
nvm install 20
```
Finally, whenever you need to ensure a specific version of Node.js is used, run:
```shell
nvm use 20
```
to set the Node.js version for the current shell session.
You can run
```shell
node -v
```
to check the version of Node.js currently being used in this shell session.
Check NVM repo for more details: [https://github.com/nvm-sh/nvm](https://github.com/nvm-sh/nvm).
Open your terminal and run:
curl -sSL https://get.wasp-lang.dev/installer.sh | sh
:::caution[Bad CPU type in executable]
Are you getting this error on a Mac (Apple Silicon)?
Given that the wasp binary is built for x86 and not for arm64 (Apple Silicon), you'll need to install Rosetta on your Mac if you are using a Mac with Mx (M1, M2, ...). Rosetta is a translation process that enables users to run applications designed for x86 on arm64 (Apple Silicon). To install Rosetta, run the following command in your terminalsoftwareupdate --install-rosetta
Once Rosetta is installed, you should be able to run Wasp without any issues.
In order to use Wasp on Windows, you need to install WSL2 (Windows Subsystem for Linux) and a Linux distribution of your choice. We recommend using Ubuntu.
You can refer to this article for a step by step guide to using Wasp in the WSL environment. If you need further help, reach out to us on Discord.
:::caution[WSL2 Docker post installation steps]
Complete those steps to ensure that PostgreSQL and Docker work correctly with Wasp in WSL2.
It is recommended to complete those post-install steps in WSL, based on the official Docker guide. These work if you are experiencing an error similar to this one.First, run
sudo groupadd docker
command to create the docker
group in case it doesn't exist. If it exists, don't worry, just continue with next steps. After that, add your current user to docker group by running
sudo usermod -aG docker $USER
where $USER is your username. After that, log out and log back in to apply the changes. Finally, run
su -s $USER
Once in WSL2, run the following command in your WSL2 environment:
curl -sSL https://get.wasp-lang.dev/installer.sh | sh
:::caution[WSL2 and file system issues]
Are you getting file system issues using WSL2?
If you are using WSL2, make sure that your Wasp project is not on the Windows file system, but instead on the Linux file system. Otherwise, Wasp won't be able to detect file changes, due to this issue in WSL2.Run the following command to verify that Wasp was installed correctly:
wasp version
Also be sure to install the Wasp VSCode extension to get the best DX, e.g. syntax highlighting, code scaffolding, autocomplete, etc.
:::tip[Installing the Wasp VSCode Extension] You can install the Wasp VSCode extension by searching for "Wasp" in the Extensions tab in VSCode, or by visiting the 🐝 Wasp VSCode Extension 🧑💻 homepage :::
From the directory where you'd like to create your new project run:
wasp new
Then select option [3] saas
from the list of templates after entering the name of your project.
This will clone a clean copy of the Open SaaS template into a new directory! 🎉
Before you start your app, you need to have a Postgres Database connected and running. With Wasp, that's super easy!
First, make sure you have Docker installed and running. If not, download and install it here
With Docker running, open a new terminal window/tab and position yourself in the app
directory:
cd app
Then run:
wasp start db
This will start and connect your app to a Postgres database for you. No need to do anything else! 🤯 Just make sure to leave this terminal window open in the background while developing. Once you terminate the process, your DB will no longer be available to your app.
Now let's create our very first database migration, to ensure the database has a correct schema. Open a new terminal tab/window and run the following command:
wasp db migrate-dev
This might take a bit since this is the first time you are running it and it needs to install all the dependencies for your Wasp project.
In the future, you will also want to run wasp db migrate-dev
whenever you make changes to your Prisma schema (Entities),
to apply those schema changes to the database.
Additionally, if you want to see or manage your DB via Prisma's DB Studio GUI, run:
wasp db studio
At this point, you should be positioned in the app/
directory and have the database running in another terminal session.
Next, copy the .env.server.example
file to .env.server
.
cp .env.server.example .env.server
.env.server
is where API keys for services like payments, email sender, and similar go, and this is where you will want to put them in later.
For now, you can leave it as it is (dummy API keys), this will be enough to run the app.
Then run:
wasp start
This will install all the dependencies and start the app (client and server) for you :)!
If the app doesn't open automatically in your browser, you can open it manually by visiting http://localhost:3000
in your browser.
At this point, you should have:
- your database running in one terminal session, likely on port
5432
. - your app running in another terminal session, the client likely on port
3000
, and the server likely on port3001
.
This SaaS app comes with a docs and blog section built with the Starlight template on top of the Astro framework. You can use this as a starting point for your own blog and documentation, if necessary.
If you do not need this, you can simply delete the blog
folder from the root of the project.
If you want to run the Starlight docs and blog, first navigate to the blog
folder:
cd ../blog
Then run:
npm install
Then start the development server:
npm run dev
Check the instructions in the terminal for the link to open the blog, it will typically be https://localhost:4321/
.
Awesome! We have our new app ready and we know how to run both it and the blog/docs! Now, in the next section, we'll give you a quick "guided tour" of the different parts of the app we created and understand how it works.
:::tip[Star our Repo on GitHub! 🌟] We've packed in a ton of features and love into this SaaS starter, and offer it all to you for free!
If you're finding this template and its guides useful, consider giving us a star on GitHub :::