Adding a custom domain

With Surge, you can use your own domain in place of a surge.sh subdomain. This means you’ll be able to publish to your-own-domain.com.

Setting a CNAME

To get started, you’ll need have a custom domain and sign into your account to manage it. now:

  1. Add a new CNAME record to your domain.
  2. Set the hostnames @ and www to:
    na-west1.surge.sh

    Depending on your domain provider, it will look something like this:

    How to add an CNAME record on NameCheap.

    If your DNS provider doesn’t support CNAME records for apex domains, you can set an A record to the following IP address instead:

    45.55.110.124
  3. Additionally, setting the hostname * to na-west1.surge.sh will allow you to deploy to custom subdomains on your domain as well.

    Adding a CNAME record for * allows you to deploy to subdomains on your own domain, like cdn.your-custom-domain.com

Instructions from your DNS provider

More detailed instructions are available directly from your domain provider:

Surge will be ready to use the domain right away, but it may take longer to propagate everywhere, depending on the internet service provider.

Deploying to your custom domain

Now you’re ready to deploy your project to your custom domain. With the Surge command line tool installed, you could run the follwing command:

surge path/to/my-project my-custom-domain.com

Saving a custom domain

You can save your custom domain so you don’t have to type it in each time you deploy. Simply add a CNAME file (no extension) to the root of the project you’re deploying, and Surge will use that automatically.

You can create a new CNAME using the following command:

echo your-own-domain.com > CNAME