How to trigger a Netlify redeploy using a link

4 min read
On this page

Static sites on Netlify are fast and reliable, but they only change when a new build happens.

That becomes a problem when you publish content based on dates. For example, you might write a blog post today but set its publish date to next week in the frontmatter. The post will not show up until Netlify runs a build after that date.

In WordPress, scheduling is built in. On a static site, you need a small workaround.

One simple trick is to create a "redeploy link" you can click anytime. The link loads a page that triggers a Netlify deploy hook, which starts a new build and publish.

What a Netlify deploy hook is#

Netlify lets you create a deploy hook URL. When Netlify receives a request to that URL, it redeploys your site.

The key detail is that deploy hooks are meant to be triggered with a POST request. A normal browser link is a GET request, so you cannot just paste the deploy hook URL into a link and expect it to work.

That is why you need a hidden page. The browser loads the page with a normal link, and the page runs a script that sends the POST request for you.

The basic approach#

You will build a page with:

  1. A weird or unlisted URL (so you do not accidentally share it)
  2. A small script that calls your Netlify deploy hook using fetch() with method: "POST"

When you visit that page, Netlify gets the POST request and starts a new redeploy.

Example: a hidden page that triggers a Netlify deploy hook#

This example uses TypeScript. You can use it in any setup where TypeScript is allowed on the client side (for example in a Vite app, Next.js, or any build step that compiles TypeScript).

Create a hidden page like /redeploy-now/ and add a script like this:

ts
const NETLIFY_DEPLOY_HOOK_URL = "https://api.netlify.com/build_hooks/YOUR_HOOK_ID"

async function triggerNetlifyRedeploy(): Promise<void> {
  const resultEl = document.getElementById("result")

  try {
    const res = await fetch(NETLIFY_DEPLOY_HOOK_URL, {
      method: "POST",
      headers: {
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
      }
    })

    if (!res.ok) {
      throw new Error(`Netlify deploy hook failed with status ${res.status}`)
    }

    if (resultEl) {
      resultEl.textContent = "Redeploy triggered. Check your Netlify deploys page in a moment."
    }
  } catch (err) {
    if (resultEl) {
      resultEl.textContent = "Could not trigger a redeploy. Double check your deploy hook URL."
    }
  }
}

triggerNetlifyRedeploy()

And your page HTML can be simple:

html
<h1>Triggering Netlify redeploy</h1>
<p id="result">Sending request to Netlify…</p>

When the page loads, it sends the POST request. You can bookmark this page and click it anytime you need a fresh build on Netlify.

Where to find the deploy hook in Netlify#

In the Netlify dashboard, you can create deploy hooks in your site settings (often under Build and deploy, then Deploy notifications, depending on the UI version).

Once you create a hook, Netlify gives you a URL that looks like a build hook endpoint. That URL is what you paste into the script.

Keep that URL private. Anyone who has it can trigger deploys on your site.

Small safety tips#

If you are adding this to a public site, treat it like a secret tool.

A few easy ideas:

  • Use a hard to guess path, not /redeploy
  • Do not link to it from your main navigation
  • Consider basic protection if your framework supports it (password, auth, or restricting access)

Even if you keep it unlisted, assume it should not be public.

When to use it#

If you need a simple way to force a rebuild for scheduled posts or other time based content, a "redeploy link" is a practical Netlify workaround. Once you set it up, you get a one click way to trigger a Netlify redeploy using a normal link, which is perfect for static sites that still need a bit of scheduling help.

Share:
Perttu Lähteenlahti

Written by

Perttu Lähteenlahti

Developer Advocate at RevenueCat and creator of Netli.fyi. Building on Netlify since 2019 and writing from hands-on experience deploying dozens of production sites.

More about the author