<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Archit Jain</title>
    <description>The latest articles on DEV Community by Archit Jain (@0xarchit).</description>
    <link>https://dev.to/0xarchit</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3147090%2F007d3c4c-8bfa-4f59-8442-87912f120d9e.jpeg</url>
      <title>DEV Community: Archit Jain</title>
      <link>https://dev.to/0xarchit</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/0xarchit"/>
    <language>en</language>
    <item>
      <title>Surge Usage Documentation | A Powerful CLI Tool for Effortless Frontend Deployments</title>
      <dc:creator>Archit Jain</dc:creator>
      <pubDate>Fri, 16 May 2025 11:45:59 +0000</pubDate>
      <link>https://dev.to/0xarchit/surge-usage-documentation-a-powerful-cli-tool-for-effortless-frontend-deploymentc-2nmn</link>
      <guid>https://dev.to/0xarchit/surge-usage-documentation-a-powerful-cli-tool-for-effortless-frontend-deploymentc-2nmn</guid>
      <description>&lt;p&gt;Hello, I'm Archit, and today I'm presenting a comprehensive guide on Surge—a tool I rely on extensively for its effortless, zero-configuration deployments. This article isn’t written arbitrarily; it encapsulates my practical experiences and insights, making it an invaluable resource for new users. I aim to help you quickly master everything from installing the Surge CLI and hosting basic sites to automating deployments with GitHub Actions and configuring custom domains. Enjoy the read and happy deploying!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Surge?
&lt;/h2&gt;

&lt;p&gt;Surge is a command-line tool designed for frictionless, zero-configuration publishing of static websites and single-page applications. In just a few seconds, you can deploy your project to Surge's global CDN, take advantage of free SSL/TLS provisioning for &lt;code&gt;surge.sh&lt;/code&gt; subdomains, custom domain support, caching controls, and advanced features such as CORS configuration, redirects, and access management (with Surge Plus).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This guide covers:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Prerequisites&lt;/li&gt;
&lt;li&gt;Installing Surge CLI&lt;/li&gt;
&lt;li&gt;Basic Hosting with Surge&lt;/li&gt;
&lt;li&gt;Hosting a React Web App with Surge&lt;/li&gt;
&lt;li&gt;GitHub Actions Workflow for Auto-Deploy React App&lt;/li&gt;
&lt;li&gt;Surge with Custom Domain&lt;/li&gt;
&lt;li&gt;Advanced Features&lt;/li&gt;
&lt;li&gt;Why Surge?&lt;/li&gt;
&lt;li&gt;Troubleshooting&lt;/li&gt;
&lt;li&gt;Best Practices&lt;/li&gt;
&lt;li&gt;Credits&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  01. Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Node.js (v14+) and npm installed.&lt;/li&gt;
&lt;li&gt;A Surge account; sign up at &lt;a href="https://surge.sh" rel="noopener noreferrer"&gt;https://surge.sh&lt;/a&gt; via cli.&lt;/li&gt;
&lt;li&gt;(Optional) Cloudflare account for free SSL on custom domains.&lt;/li&gt;
&lt;li&gt;I'm using npm throughout this guide, but you can opt for your preferred package manager if needed.&lt;/li&gt;
&lt;li&gt;I'm considering &lt;code&gt;./dist&lt;/code&gt; as the output path for Vite. Feel free to adjust it as needed.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  02. Installing Surge CLI
&lt;/h2&gt;

&lt;p&gt;First, install Surge globally using npm or Yarn:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--global&lt;/span&gt; surge
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installation, verify by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;surge &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  03. Basic Hosting with Surge
&lt;/h2&gt;

&lt;p&gt;i. &lt;strong&gt;Build or prepare your static site&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ensure your static files (HTML, CSS, JS) are in a local folder, e.g., &lt;code&gt;public/&lt;/code&gt; or &lt;code&gt;dist/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;ii. &lt;strong&gt;Login to Surge&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   surge login
   &lt;span class="c"&gt;# Enter your email and password when prompted&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;iii. &lt;strong&gt;Publish your site&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   surge ./dist your-subdomain.surge.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;./dist&lt;/code&gt; is the local folder containing static assets&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;your-subdomain.surge.sh&lt;/code&gt; is your chosen subdomain&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;iv. &lt;strong&gt;Update or remove deployments&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To update, run the same &lt;code&gt;surge&lt;/code&gt; command with updated folder contents.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To remove, use the CLI command:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; surge teardown your-subdomain.surge.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  GitHub Actions Deployment for Static Sites
&lt;/h3&gt;

&lt;p&gt;Automate your HTML/CSS/JS site deployment with this workflow. Adjust &lt;code&gt;project&lt;/code&gt; if your assets live elsewhere.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deploy Static Site to Surge&lt;/span&gt;

&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;main&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Checkout code&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v4&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install Surge CLI&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm install --global surge&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deploy to Surge&lt;/span&gt;
        &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;SURGE_TOKEN&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.SURGE_TOKEN }}&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;surge --project ./ --domain &amp;lt;your-prefered-surge-subdomain&amp;gt;.surge.sh --token $SURGE_TOKEN&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Change path and domain accordingly*&lt;br&gt;
For custom domain (dns updated) use&lt;/p&gt;


&lt;pre class="highlight shell"&gt;&lt;code&gt;surge &lt;span class="nt"&gt;--project&lt;/span&gt; ./ &lt;span class="nt"&gt;--domain&lt;/span&gt; xyz.com &lt;span class="nt"&gt;--token&lt;/span&gt; &lt;span class="nv"&gt;$SURGE_TOKEN&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  04. Hosting a React Web App with Surge
&lt;/h2&gt;

&lt;p&gt;React apps built with Create React App output static files ready for Surge.&lt;/p&gt;

&lt;p&gt;i. &lt;strong&gt;Create a production build&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This generates a &lt;code&gt;dist/&lt;/code&gt; folder with optimized production assets.&lt;/p&gt;

&lt;p&gt;ii. &lt;strong&gt;Deploy to Surge&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   surge ./dist my-react-app.surge.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Pro Tip:&lt;/strong&gt; Add a &lt;code&gt;deploy&lt;/code&gt; script to your &lt;code&gt;package.json&lt;/code&gt; to simplify deployment:&lt;/p&gt;


&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;package.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...other&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;scripts...&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"deploy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm run build &amp;amp;&amp;amp; surge ./dist my-react-app.surge.sh"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Now you can deploy with:&lt;/p&gt;


&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;iii. &lt;strong&gt;Enable SPA routing (single-page application)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Add a &lt;code&gt;200.html&lt;/code&gt; fallback so all client-side routes resolve:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;cd &lt;/span&gt;dist
   &lt;span class="nb"&gt;cp &lt;/span&gt;index.html 200.html
   surge &lt;span class="nb"&gt;.&lt;/span&gt; my-react-app.surge.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  05. GitHub Actions Workflow for Auto-Deploy React App
&lt;/h2&gt;

&lt;p&gt;Automate your deployments on every push to the &lt;code&gt;main&lt;/code&gt; branch.&lt;/p&gt;

&lt;p&gt;Create &lt;code&gt;.github/workflows/deploy-react-surge.yml&lt;/code&gt; in your repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deploy React App to Surge&lt;/span&gt;

&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;main&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Build and Deploy&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;

    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Checkout code&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v4&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install Node.js&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/setup-node@v3&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;node-version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;18'&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Install dependencies&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm install&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Build&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npm run build&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Copy fallback for SPA&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;cd dist&lt;/span&gt;
          &lt;span class="s"&gt;cp index.html 200.html&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deploy to Surge&lt;/span&gt;
        &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;SURGE_TOKEN&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.SURGE_TOKEN }}&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;npm install --global surge&lt;/span&gt;
          &lt;span class="s"&gt;surge --project ./dist --domain &amp;lt;your-prefered-surge-subdomain&amp;gt;.surge.sh --token $SURGE_TOKEN&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Getting your Surge token
&lt;/h3&gt;

&lt;p&gt;First, you’ll need your token from the Surge CLI. This secret key lets services like GitHub Actions authenticate and publish projects on your behalf. Get your Surge token by running the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;surge token
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll be asked to log in again, and afterwards your token will be displayed like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;token: ar892djio57hd......
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, add this token as a secret named &lt;code&gt;SURGE_TOKEN&lt;/code&gt; in your GitHub repository settings.&lt;/p&gt;




&lt;h2&gt;
  
  
  06. Surge with Custom Domain
&lt;/h2&gt;

&lt;p&gt;To use a custom domain with Surge:&lt;/p&gt;

&lt;p&gt;i. &lt;strong&gt;Add your domain to the project&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   surge ./dist your-domain.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ii. &lt;strong&gt;Configure DNS&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a CNAME record for your domain (e.g., &lt;code&gt;www&lt;/code&gt; or &lt;code&gt;@&lt;/code&gt;) pointing to &lt;code&gt;geo.surge.world&lt;/code&gt; (or other appropriate Surge endpoint but this is new and it automatically routes traffic to the most optimal Surge datacenter based on location).&lt;/li&gt;
&lt;li&gt;If using an apex/naked domain, add an ALIAS/ANAME record pointing to &lt;code&gt;45.55.110.124&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;iii. &lt;strong&gt;Verify SSL&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Surge provides automatic SSL/TLS via Let’s Encrypt for &lt;code&gt;surge.sh&lt;/code&gt; subdomains. For custom domains, SSL requires Surge Plus or a third-party service like Cloudflare. It may take a few minutes for certificates to be issued with Surge Plus.&lt;/p&gt;

&lt;p&gt;iv. &lt;strong&gt;Free SSL with Cloudflare&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Surge's free plan does not include SSL for custom domains. However, you can use Cloudflare's free tier to enable HTTPS:&lt;/p&gt;

&lt;p&gt;a. Create a Cloudflare account and add your domain.&lt;br&gt;
   b. Update your domain's nameservers to the ones provided by Cloudflare.&lt;br&gt;
   c. In the Cloudflare dashboard, navigate to &lt;strong&gt;SSL/TLS&lt;/strong&gt; settings and set the encryption mode to &lt;strong&gt;Flexible&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgkqege2q2r8xz8kwraac.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgkqege2q2r8xz8kwraac.png" alt="Cloudflare dashboard ssl config screenshot" width="800" height="541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;d. Ensure your DNS records (CNAME or ALIAS) point to your Surge endpoint (e.g., &lt;code&gt;geo.surge.world&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;With Flexible mode, Cloudflare will serve HTTPS to your visitors while connecting to Surge over HTTP, providing free SSL encryption.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Cloudflare ssl setup can take anywhere between 15 minutes to 24 hours.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;v. &lt;strong&gt;Managing multiple domains&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can deploy the same folder to multiple domains in one command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   surge ./dist www.example.com example.net hello.example.org
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  07. Advanced Features
&lt;/h2&gt;

&lt;p&gt;Advanced features like CORS, redirects, and password protection require Surge Plus.&lt;/p&gt;

&lt;p&gt;i. &lt;strong&gt;CORS Configuration&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Add a &lt;code&gt;CORS&lt;/code&gt; file in your project root to control cross-origin requests (requires Surge Plus). For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Access-Control-Allow-Origin: *
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ii. &lt;strong&gt;Redirects and Rewrites&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Use a &lt;code&gt;ROUTER&lt;/code&gt; file to manage redirects and clean URLs. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   301 /old-path /new-path
   301 /contact /about
   200 /api/* https://api.example.com/:splat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;iii. &lt;strong&gt;Access Control&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Password-protect your site with an &lt;code&gt;AUTH&lt;/code&gt; file (requires Surge Plus):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   username:password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;iv. &lt;strong&gt;Ignore File and Directories&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Just like &lt;code&gt;.gitignore&lt;/code&gt;, if you want to exclude specific files or directories from deployment, create a &lt;code&gt;.surgeignore&lt;/code&gt; file and list them inside. &lt;br&gt;
To override something on the default ignore list or make it must include, add it to your own &lt;code&gt;.surgeignore&lt;/code&gt; file with an &lt;strong&gt;exclamation mark&lt;/strong&gt; (&lt;code&gt;!&lt;/code&gt;) in front.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;.git
.vscode
&lt;span class="o"&gt;!&lt;/span&gt;src/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;v. &lt;strong&gt;Version Management&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Surge does not support direct rollbacks. To revert to a previous version, manually redeploy the desired build:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   surge ./previous-build my-site.surge.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To remove a deployment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   surge teardown my-site.surge.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  08. Why To Choose Surge?
&lt;/h2&gt;

&lt;p&gt;Surge shines in specific use cases:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Simplicity &amp;amp; Speed&lt;/strong&gt;: Surge excels at pure simplicity and speed with its zero-configuration approach and lightning-fast deployments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CLI-Native Workflow&lt;/strong&gt;: If you prefer command-line workflows over GUI interfaces and git-based deployments, Surge offers the most streamlined experience.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Quick Prototyping&lt;/strong&gt;: For rapid prototyping and sharing static builds, nothing beats the speed and ease of &lt;code&gt;surge ./folder my-project.surge.sh&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Low Overhead&lt;/strong&gt;: No need for repository setup, build configurations, or web interfaces - just deploy directly from any directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Multiple Domain Support&lt;/strong&gt;: The ability to deploy to multiple domains in a single command is uniquely powerful.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Surge is ideal when you need the fastest path from local files to live website with minimal configuration. While platforms like Netlify, vercel and Cloudflare Pages offer more features (continuous integration, server-side functions, etc.), Surge's focused approach makes it the perfect tool for developers who value simplicity and speed.&lt;/p&gt;




&lt;h2&gt;
  
  
  09. Troubleshooting
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Authentication errors&lt;/strong&gt;: Run &lt;code&gt;surge logout &amp;amp;&amp;amp; surge login&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DNS propagation delays&lt;/strong&gt;: Wait up to 24 hours; verify using &lt;code&gt;dig&lt;/code&gt; or &lt;code&gt;nslookup&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SSL issues&lt;/strong&gt;: Check case-sensitive CNAME records and ensure Cloudflare's SSL mode is set correctly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build failures&lt;/strong&gt;: Confirm local build works (&lt;code&gt;npm run build&lt;/code&gt;) before deploying.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  10. Best Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Keep your &lt;code&gt;build&lt;/code&gt; or &lt;code&gt;dist&lt;/code&gt; directory clean and up to date.&lt;/li&gt;
&lt;li&gt;Version control your Surge configuration files (&lt;code&gt;CORS&lt;/code&gt;, &lt;code&gt;ROUTER&lt;/code&gt;, &lt;code&gt;AUTH&lt;/code&gt;) in the project root.&lt;/li&gt;
&lt;li&gt;Automate deployments on pull request previews using branches and surge subdomains.&lt;/li&gt;
&lt;li&gt;Monitor performance using Lighthouse or a CDN analytics tool.&lt;/li&gt;
&lt;li&gt;Regularly audit and update security headers.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  11. Credits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;My personal experience in using Surge&lt;/li&gt;
&lt;li&gt;Official Surge.sh documentation: &lt;a href="https://surge.sh/help/" rel="noopener noreferrer"&gt;https://surge.sh/help/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;DNS configuration insights from &lt;a href="https://geo.surge.world/" rel="noopener noreferrer"&gt;https://geo.surge.world/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Additional insights from various articles on Medium and Dev.to&lt;/li&gt;
&lt;li&gt;ChatGPT for Markdown formatting, language improvements, and fixations&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Happy deploying with Surge!&lt;/p&gt;

&lt;p&gt;Authored By: &lt;a href="https://0xarchit.carrd.co" rel="noopener noreferrer"&gt;0xArchit&lt;/a&gt;&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>staticwebapps</category>
      <category>opensource</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
