13 Deploying

 

This chapter covers

  • Deploying to any HTTP server
  • Using Netlify
  • Using Vercel (formerly ZEIT)
  • Using Docker

Writing a Svelte app is lots of fun, and they are easy to run locally. But eventually you’ll want to deploy apps to a server that enables others to use them. There are many more deployment options than we will cover here, but we will discuss some popular choices.

Some services, such as Netlify and Vercel, support registering a source repository (such as GitHub, GitLab, or Bitbucket). After you do this, they watch the repository for changes. Every time changes are pushed, they rebuild the web app and serve the resulting files.

13.1 Deploying to any HTTP server

It is easy to deploy a Svelte application to any HTTP server. To demonstrate this, we will use the Node-based Express server. Here are the steps:

  1. cd to the top project directory.
  2. Enter npm run build to create files in the public/build directory.
  3. Create a server directory in the top project directory.
  4. cd to the server directory.
  5. Enter npm init and answer the questions it asks in order to create a package .json file. Alternatively enter npm init --yes to use the default values instead of having to answer questions.
  6. Install Express by entering npm install express.
  7. Create a server.js file containing the following:

13.2 Using Netlify

13.2.1 Netlify from the website

13.2.2 Netlify from the command line

13.2.3 Netlify plans

13.3 Using Vercel