Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions content/docs/campaigns/hosting/cloudflare-workers.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: Deploy a campaign to Cloudflare Workers
description: Connect a GitHub repository and serve the Page Kit build with Workers Static Assets.
audience: [developer]
---

## Connect GitHub

1. In Cloudflare, open **Workers & Pages → Create application**. On the **Create an app** screen, select **Connect GitHub**. The **Continue to Pages** link opens the legacy Pages workflow.
2. Give Cloudflare access to the campaign repository and select it. Choose a Worker name, such as `spring-campaign`.
3. In the repository, commit a `wrangler.jsonc` alongside the package.json that builds the site. Use the same Worker name you chose in Cloudflare. If the repository already has a Wrangler configuration, update that file.

```json
{
"name": "spring-campaign",
"compatibility_date": "2026-11-18",
"assets": { "directory": "./_site" }
}
```

## Build and deploy

Set the root directory to the folder containing that configuration. Set **Build command** to `npm run build` and **Deploy command** to `npx wrangler deploy`. Page Kit generates the files in `_site/` and Wrangler uploads them as the Worker's static assets. If you use redirect rules, commit `_redirects` alongside package.json and use `npm run build && cp _redirects _site/_redirects` as the build command.

Confirm the production branch and deploy. Open the campaign's landing path on the assigned `workers.dev` hostname. See [Workers Builds configuration](https://developers.cloudflare.com/workers/ci-cd/builds/configuration/).

## Preview a change

Enable non-production branch builds and use `npx wrangler versions upload` as the non-production deploy command. Push a branch and open the version URL from its build. Register that hostname as **Development** in Campaigns App and complete the [campaign preview checks](/docs/campaigns/hosting#verify-the-preview). See [Worker version URLs](https://developers.cloudflare.com/workers/versions-and-deployments/version-urls/).

## Connect the campaign domain

With the domain owner's approval, open the Worker and choose **Settings → Domains & Routes → Add → Custom Domain**. Enter the campaign hostname in an active Cloudflare zone on the same account. Cloudflare provisions the DNS record and certificate. Verify the landing page and checkout over HTTPS, then complete the [launch checks](/docs/campaigns/hosting#launch-and-recover). See [custom domain requirements](https://developers.cloudflare.com/workers/configuration/routing/custom-domains/).

To recover a previous build, open the Worker's **Deployments**, select the known-good version and roll back. Verify the campaign path on the live hostname.
23 changes: 23 additions & 0 deletions content/docs/campaigns/hosting/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: Host a NEXT campaign
description: Publish Page Kit output and verify the preview and live campaign domains.
audience: [developer]
---

Choose [Cloudflare Workers](/docs/campaigns/hosting/cloudflare-workers), [Netlify](/docs/campaigns/hosting/netlify), or [Vercel](/docs/campaigns/hosting/vercel). For Render and other static hosts, use the shared build, preview and launch steps below. The recipes assume a Page Kit project. For an existing custom build, use the repository’s own build command, working directory and output folder.

## Prepare the build

From the folder containing the campaign’s package.json and lockfile, run `npm ci` and `npm run build`. Locate the landing and checkout pages under `_site/`. Use the same Node major version on the host. Publish only the build output. Page Kit uses the public Campaign API key in the browser. Keep private Admin API tokens out of source, build output and client settings.

## Verify the preview

1. Open the host’s preview for the reviewed commit. In Campaigns App → Settings → Allowed Domains, register the **exact hostname** as **Development**. For a changing preview URL, register the new hostname or use a stable branch hostname.
2. Open the actual campaign path, such as `/spring-offer/landing/`. Verify styles, images, package prices and navigation through checkout. Paste a representative old ad URL with test click parameters and confirm the intended landing page receives them. If the original hostname serves the storefront, configure the redirect there.
3. Run approved checkout-path tests against the preview. Confirm test orders in the dashboard and coordinate fulfillment cleanup. Development domains exclude NEXT analytics visits, but vendor pixels can still fire. See [tracking QA](/docs/campaigns/tracking/testing-and-troubleshooting) and [test orders](/docs/testing).

## Launch and recover

Have the domain owner confirm the campaign hostname before changing DNS. Check HTTPS and the same landing and checkout paths on that hostname. Get payment-method confirmation for this store. With launch approval, mark the live hostname **Production** in Allowed Domains and send traffic to the verified address. See [campaign domains](/docs/campaigns#domains).

If checkout breaks, pause traffic, restore a known-good deployment and verify the public URL. A host rollback restores page files. Review any changed prices or offers separately in Campaigns App.
1 change: 1 addition & 0 deletions content/docs/campaigns/hosting/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"title":"Hosting","pages":["index","cloudflare-workers","netlify","vercel"]}
30 changes: 30 additions & 0 deletions content/docs/campaigns/hosting/netlify.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Deploy a campaign to Netlify
description: Connect a Page Kit repository, verify a branch preview and configure a campaign domain on Netlify.
audience: [developer]
---

## Import the campaign from GitHub

1. In the Netlify team that will own the campaign, open **Projects → Add new project → Import an existing project**. Choose **GitHub**, authorize Netlify to access the campaign repository, then select it.
2. Choose the branch to publish. Leave **Base directory** blank if the Page Kit build runs at the repository root. For a standalone project in a subfolder, enter that folder’s path.
3. Set **Build command** to `npm run build`, or to `npm run build && cp _redirects _site/_redirects` if the campaign uses [redirect rules](#connect-the-live-hostname), and **Publish directory** to `_site`. Netlify resolves the publish directory relative to the base directory. If the repository contains a `netlify.toml`, check its build settings first. They override matching dashboard values.
4. Select **Publish**. When the deployment succeeds, open the campaign’s landing path on the assigned hostname and check that its images and checkout link load.

See [Netlify’s Git import walkthrough](https://docs.netlify.com/start/quickstarts/deploy-from-repository/) and [build settings](https://docs.netlify.com/build/configure-builds/overview/).

## Review a branch preview

Open a pull request targeting the production branch. Follow the Netlify Deploy Preview link for that PR. Copy the hostname and complete the [preview checks](/docs/campaigns/hosting#verify-the-preview). Record the commit and tested campaign URL for the person approving release.

## Connect the live hostname

In Domain management, add the campaign hostname as a production domain. Apply the DNS record Netlify shows and check certificate provisioning.

Commit `_redirects` alongside package.json. The build command from step 3 copies it into `_site/`, so each deployment includes the rules. For a moved ad path, a rule such as `/products/old-name /spring-offer/landing/ 301` redirects that path. Test with the actual ad parameters.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: The copy is still conditional on the build command chosen at step 3

This line says the build command from step 3 copies _redirects into _site/, but step 3 keeps the plain npm run build for any campaign that was not already known to use redirect rules. A reader who imports first and only adds _redirects when they reach this section still deploys with npm run build, so the file never reaches _site/ and moved ad paths 404 after the first automated deploy. Tell them to switch the build command (or the netlify.toml build command) to include the copy at the point where the rules are added.

Suggested change
Commit `_redirects` alongside package.json. The build command from step 3 copies it into `_site/`, so each deployment includes the rules. For a moved ad path, a rule such as `/products/old-name /spring-offer/landing/ 301` redirects that path. Test with the actual ad parameters.
Commit `_redirects` alongside package.json. If step 3 used the plain `npm run build`, change the build command (or the `netlify.toml` build command) to `npm run build && cp _redirects _site/_redirects` so each deployment includes the rules. For a moved ad path, a rule such as `/products/old-name /spring-offer/landing/ 301` redirects that path. Test with the actual ad parameters.


## Release and rollback

Merging to the configured production branch publishes the new build. Follow the [launch checks](/docs/campaigns/hosting#launch-and-recover) before directing ads to it. Open Deploys, select the previous successful production deploy and publish it.

See the [Netlify deployment documentation](https://docs.netlify.com/deploy/deploy-types/deploy-previews/).
32 changes: 32 additions & 0 deletions content/docs/campaigns/hosting/vercel.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Deploy a campaign to Vercel
description: Connect a Page Kit repository, verify a branch preview and configure a campaign domain on Vercel.
audience: [developer]
---

## Import the campaign from GitHub

Choose a Vercel team on a plan that permits commercial campaigns. [Vercel Hobby plan terms](https://vercel.com/docs/plans/hobby).

1. In the team dashboard, choose **Add New… → Project**. Under **Import Git Repository**, connect GitHub if prompted. Select the GitHub account or organization that owns the campaign and click **Import** beside its repository. If the repo is missing, check the Vercel GitHub App’s repository access.
2. Set **Root Directory** to the folder where the Page Kit build runs. Keep the repository root for a standard project. Choose **Other** for **Framework Preset**.
3. In the build settings, enable the overrides for **Build Command** and **Output Directory**. Enter `npm run build` and `_site`, respectively. With the Other preset, Vercel otherwise serves `public` if present or the project root. Keep the default install command for a standard npm project. If the repo has a `vercel.json`, check its `buildCommand` and `outputDirectory` overrides.
4. Select **Deploy**. Once the deployment is ready, open the campaign’s landing path on its assigned hostname and check that its images and checkout link load.

See the [Vercel import screen](https://vercel.com/new) and [build settings](https://vercel.com/docs/builds/configure-a-build).

## Review a branch preview

Push a non-production branch and open the Preview deployment. If Deployment Protection is enabled, arrange reviewer access before running browser QA. Copy the hostname and complete the [preview checks](/docs/campaigns/hosting#verify-the-preview). Record the commit and tested campaign URL for the person approving release.

## Connect the live hostname

Under project Settings → Domains, add the campaign hostname to Production. Apply the DNS record Vercel shows and wait for verification and HTTPS.

Define legacy paths in the project’s `vercel.json` redirects array. For example, an entry with source `/products/old-name`, destination `/spring-offer/landing/` and permanent set to true returns a permanent redirect.

## Release and rollback

Merging to the configured production branch publishes the new build. Follow the [launch checks](/docs/campaigns/hosting#launch-and-recover) before directing ads to it. Use Instant Rollback to restore an eligible previous production deployment, or revert the source change and redeploy.

See the [Vercel deployment documentation](https://vercel.com/docs/deployments/environments).
21 changes: 9 additions & 12 deletions content/docs/campaigns/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Orders created through a campaign are regular store orders. They appear in the s
Give an agent a funnel URL, existing repo or saved Map using the [campaign agent guide](/docs/agent-setup). It can inspect, plan and prepare a local concept before store access is available. The [Campaigns OS Start guide](https://campaigns.nextcommerce.com/start/) also provides the Workspace/Map route. Keep your existing builder and host; the Page Kit quick start below is the reference path for a new static project.
</Callout>

For direct project scaffolding, use the **[Campaign Page Kit](https://github.com/NextCommerceCo/campaign-page-kit)**: a CLI that scaffolds an SDK-ready starter template, runs a hot-reload dev server, and outputs a static site you can deploy to Netlify, Cloudflare Pages, Vercel, or any static host.
For direct project scaffolding, use the **[Campaign Page Kit](https://github.com/NextCommerceCo/campaign-page-kit)**: a CLI that scaffolds an SDK-ready starter template, runs a hot-reload dev server, and outputs a static site you can deploy to Netlify, Cloudflare Workers, Vercel, or any static host.

## Quick Start

Expand Down Expand Up @@ -291,25 +291,22 @@ Add `--json` for machine-readable stdout. See the [page-kit CLI reference](https

## Hosting

`npm run build` outputs a fully static site to `_site/` — no server, no runtime, just HTML, CSS, JS, and images. That means you can host it on any static host. Configure your provider with:
Choose a host and follow the [campaign hosting guide](/docs/campaigns/hosting) to publish a preview, authorize its domain and check the campaign before launch.

- **Build command:** `npm run build`
- **Publish directory:** `_site`
### Netlify

Make sure to add the host's domain (e.g. `*.netlify.app`, your custom domain) to your campaign's **authorized domains** in the Campaigns App so the SDK can call the API from that origin.
[Deploy a campaign to Netlify](/docs/campaigns/hosting/netlify).

### Netlify
### Cloudflare Workers

[Netlify](https://www.netlify.com/) — connect your Git repo, Netlify auto-detects the build command and serves `_site/` on a `*.netlify.app` subdomain (custom domains free). Best for: zero-config Git deploys, branch previews, instant rollbacks.
[Deploy a campaign to Cloudflare Workers](/docs/campaigns/hosting/cloudflare-workers).

### Cloudflare Pages
### Vercel

[Cloudflare Pages](https://pages.cloudflare.com/) — connect your Git repo, set framework preset to "None", build command to `npm run build`, output directory to `_site`. Best for: global edge network, generous free tier, fast cold starts via Cloudflare's CDN.
[Deploy a campaign to Vercel](/docs/campaigns/hosting/vercel).

### Render

[Render](https://render.com/) — create a new **Static Site**, point it at your repo, set publish path to `_site`. Best for: a single dashboard alongside any backend services you already run on Render.

### Other static hosts

The same `_site/` output works on **[Vercel](https://vercel.com/)**, **[GitHub Pages](https://pages.github.com/)**, **[AWS S3 + CloudFront](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html)**, **[Surge](https://surge.sh/)**, or any host that serves static files. There is no server-side rendering and no runtime dependency on Node, so any plain static host will do.
Other static hosting options include AWS S3 with CloudFront and Surge. GitHub Pages excludes commercial transaction sites under its [usage limits](https://docs.github.com/en/pages/getting-started-with-github-pages/github-pages-limits).
1 change: 1 addition & 0 deletions content/docs/campaigns/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"index",
"templates",
"page-kit",
"hosting",
"tracking",
"[Playground](/playground)",
"---Cart SDK---",
Expand Down
4 changes: 2 additions & 2 deletions content/docs/campaigns/page-kit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ Every template also has access to an `environment` variable indicating the curre
{% endunless %}
```

Override the default by setting `CPK_ENV` — useful for build pipelines like Netlify or GitHub Pages where you want a custom value such as `staging`:
Override the default by setting `CPK_ENV` — useful for build pipelines like Netlify or Cloudflare Workers where you want a custom value such as `staging`:

```bash
CPK_ENV=staging npm run build
Expand Down Expand Up @@ -416,7 +416,7 @@ Already-optimized images are skipped and reported in a debug line above the summ
npm run build
```

Output is written to `_site/` — fully static, no server, no runtime. From there, push to any static host. See **Hosting** in [Getting Started](./) for provider-specific setup (Netlify, Cloudflare Pages, Render, Vercel, etc.).
Output is written to `_site/` — fully static, no server, no runtime. From there, push to any static host. See **Hosting** in [Getting Started](./) for provider-specific setup (Netlify, Cloudflare Workers, Render, Vercel, etc.).

The command exits `1` when any page fails to render, and `0` otherwise. Build warnings (below) never change the exit code.

Expand Down