# Static sites

> Publish to a Next.js static export with a deploy hook. RootSmith starts a new build of your site each time you publish.

Source: https://docs.rootsmith.io/docs/publishing/static-sites.md

Use this when your host serves only files, such as a Next.js site with
`output: "export"`. A static site has no refresh handler, so RootSmith starts
a build instead. A publish takes as long as one build.

## 1. Set up the SDK without the handler

Follow the [Next.js SDK](https://docs.rootsmith.io/docs/publishing/nextjs.md) guide with two changes:

- Leave out `app/api/rootsmith/route.ts` and `ROOTSMITH_CONNECTION_SECRET`.
- Return every page from `generateStaticParams`:

```tsx title="app/[...path]/page.tsx"
export async function generateStaticParams() {
  const pages = await rootSmith.listAllPages()
  return pages.map((page) => ({ path: page.path.slice(1).split("/") }))
}
```

Set `ROOTSMITH_API_URL` and `ROOTSMITH_SITE_ID` in your host's build
environment.

## 2. Create a deploy hook

Create a deploy hook in your host, such as Vercel, Netlify, or Cloudflare
Pages. It must be a public HTTPS URL without a query string.

## 3. Save it in RootSmith

In **Publishing**, leave the **Delivery endpoint** empty. Under
**Without an SDK connection**, choose **Static site deploy hook**, paste the
hook URL, and save.

RootSmith never shows a saved hook URL again. To change it, paste a new one.
An agent sets this with `update_publishing_settings`, using
`fallbackDelivery: "build"` and the URL in `webhookUrl`.

## What happens when you publish

1. RootSmith makes the new version public in its API.
2. It sends an empty `POST` to your deploy hook.
3. Your build reads the new version.
4. RootSmith checks the live page every five minutes for 24 hours and marks
   it published when it finds the version marker.

If the hook fails, the previous version stays public.

## Merged pages

A static site can't send a redirect for a merged page. Add the redirects in
your host's configuration, then confirm them in RootSmith. Retiring the old
pages starts a build that removes them.
