Skip to main content
Version: 0.23

Self-Hosted

If you have your server or rent out a server, you can self-host your Wasp apps. Self-hosting your apps gives you full control over your apps and their data. It can be more cost-effective than a cloud provider since you can deploy multiple apps on a single server. However, you'll need to manage the server yourself, which can be time-consuming and require some technical knowledge.

Guidesโ€‹

We have step-by-step guides for deploying your Wasp app on your server with different methods. Check out the guides below:

guide

Deploying Wasp with Caprover on your server ยป

Uses Caprover, Github Actions, Github Container Registry

guide

Deploying Wasp with Coolify on your server ยป

Uses Coolify, Github Actions, Github Container Registry

guide

Deploying Wasp with Docker on your server ยป

Uses Ubuntu, Git, Caddy, Docker

Manual deploymentโ€‹

We will show you a general overview of the architecture of a self-hosted Wasp app and the steps you need to take to deploy your app on your server. This is a more manual process than using the guides above, but it gives you more control over your deployment and you'll learn how everything works. If you are looking for a more guided deployment, check out the guides above.

What you'll needโ€‹

To successfully self-host your Wasp app, you need to have the following:

  • A server with a public IP address. There are many cloud providers you can use to rent a server. Some popular ones are AWS, DigitalOcean, OVH, and Hetzner.

  • A domain name, for example, myapp.com (needed for HTTPS support).

Architectureโ€‹

To self-host your Wasp app, you'll follow these general steps:

  1. From your app's code, let Wasp build a server app and a client app.
  2. Set up the server environment variables on the server.
  3. Run a database on the server or use a managed database service.
  4. Run the server app on the server, with or without Docker.
  5. Serve the client app with a static file server.
  6. Set up a reverse proxy on the server to be able to use a domain name with HTTPS for your app.
One of many possible self-hosting setups
One possible self-hosting setup

Stepsโ€‹

  1. Install Docker, Node.js and Wasp CLI.
  2. Get your app's source code.
    • We recommend using Git to clone your app's repository and then pulling the latest changes when you want to deploy a new version. You can use any other method to get your app's code on the server.
  3. Build your app with wasp build.
  4. Build and run the server app.
    • Wasp gives you a Dockerfile in the .wasp/out directory that you can use to build and run the server app.
    • We are using Docker to run the server app, but you can run it without Docker if you prefer - just make sure to replicate the setup in the Dockerfile.
    • When you run the server app with Docker, you need to setup the server env variables. You can do this with a .env file or by passing the env variables directly to the docker run command.
  5. Start the database on the server or use a managed database service.
    • We usually run the database in Docker on the same server, but you can run the database directly on the server.
    • You can also use a managed database service which you can connect to from your server. This is a great option if you don't want to manage the database yourself, but it can be more expensive.
  6. Build the client app into static files.
    • Wasp outputs the client app in the .wasp/out/web-app directory.
  7. Install and set up a reverse proxy to serve your client and server apps.
    • There are many great choices for reverse proxies, like Nginx, Caddy, and Traefik.
    • Make sure to set up the reverse proxy to serve the client app's static files and to proxy requests to the server app.
  8. Point your domain(s) to your server's IP address.
    • We recommend setting myapp.com for the client and api.myapp.com for the server.
    • The reverse proxy should serve the client app on myapp.com and proxy requests to the server app on api.myapp.com. Make sure your env variables are using these client and server URLs.

Database setupโ€‹

By default, our self-hosted deployment methods run the database on your server. When you run the database on your server, you need to take care of backups, updates, and scaling. We suggest setting up PostgresSQL periodic backups and/or taking snapshots of your server's disk. In case something bad happens to your server, you can restore your database from the backups.

If you prefer not to manage the database yourself, you can use a managed database service. The service provider takes care of backups, updates, and scaling for you but it can be more expensive than running the database on your server. Some popular managed database services are AWS RDS, DigitalOcean Managed Databases, and Supabase.