SSL Certificates

This guide has an example repo: examples/https-ssl-certificates
npm start -- --secure

Snowpack provides an easy way to use a local HTTPS server during development through the use of the --secure flag. When enabled, Snowpack will look for a snowpack.key and snowpack.crt file in the root directory and use that to create an HTTPS server with HTTP2 support enabled. Optionally, you may customize which TLS certificate and private key files by passing them directly to devOptions.secure.

const fs = require('fs');

const cert = fs.readFileSync('/path/to/server.crt');
const key = fs.readFileSync('/path/to/server.key');

module.exports = {
  devOptions: {
    secure: {cert, key},
  },
};

Generating SSL Certificates

You can automatically generate credentials for your project via either:

In most situations you should add personally generated certificate files (snowpack.key and snowpack.crt) to your .gitignore file.