From 590eb7013ec09938ff88c04727610d0df75c2156 Mon Sep 17 00:00:00 2001 From: Devin Michael Date: Wed, 18 Nov 2026 09:59:16 +0700 Subject: [PATCH 1/7] Document production hosting for NEXT campaigns --- .../campaigns/hosting/cloudflare-pages.mdx | 25 +++++++++++++++++++ content/docs/campaigns/hosting/index.mdx | 23 +++++++++++++++++ content/docs/campaigns/hosting/meta.json | 1 + content/docs/campaigns/hosting/netlify.mdx | 25 +++++++++++++++++++ content/docs/campaigns/hosting/vercel.mdx | 25 +++++++++++++++++++ content/docs/campaigns/index.mdx | 19 ++++++-------- content/docs/campaigns/meta.json | 1 + content/docs/campaigns/page-kit.mdx | 2 +- 8 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 content/docs/campaigns/hosting/cloudflare-pages.mdx create mode 100644 content/docs/campaigns/hosting/index.mdx create mode 100644 content/docs/campaigns/hosting/meta.json create mode 100644 content/docs/campaigns/hosting/netlify.mdx create mode 100644 content/docs/campaigns/hosting/vercel.mdx diff --git a/content/docs/campaigns/hosting/cloudflare-pages.mdx b/content/docs/campaigns/hosting/cloudflare-pages.mdx new file mode 100644 index 0000000..80863f9 --- /dev/null +++ b/content/docs/campaigns/hosting/cloudflare-pages.mdx @@ -0,0 +1,25 @@ +--- +title: Deploy a campaign to Cloudflare Pages +description: Connect a Page Kit repository, verify a branch preview and configure a campaign domain on Cloudflare Pages. +audience: [developer] +--- + +## Connect the repository + +In Workers & Pages, create a **Pages** project, connect Git and select the campaign repository. Select the production branch and framework preset **None**. Set the root directory to the folder containing the build package.json. For a standard Page Kit project, enter `npm run build` as the build command and `_site` as the output directory. Match the Node version used locally. Start the deployment and check the build log for successful publication. + +## Review a branch preview + +Push a branch and open its preview deployment. For repeat QA use the branch alias shown by Pages. 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 **Custom domains**, add the campaign subdomain first. Follow the DNS instructions for that hostname and wait for activation. + +Include a `_redirects` file in the final `_site/` output. For a campaign subdomain whose root should send visitors to the storefront, use the rule `/ https://shop.example.com/ 301`, replacing the destination. Keep campaign paths outside that rule. + +## 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. In Deployments, select the known-good production deployment and roll back to it. + +See the [Cloudflare Pages deployment documentation](https://developers.cloudflare.com/pages/configuration/preview-deployments/). diff --git a/content/docs/campaigns/hosting/index.mdx b/content/docs/campaigns/hosting/index.mdx new file mode 100644 index 0000000..4c6ee4f --- /dev/null +++ b/content/docs/campaigns/hosting/index.mdx @@ -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 Pages](/docs/campaigns/hosting/cloudflare-pages), [Netlify](/docs/campaigns/hosting/netlify), or [Vercel](/docs/campaigns/hosting/vercel). 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. diff --git a/content/docs/campaigns/hosting/meta.json b/content/docs/campaigns/hosting/meta.json new file mode 100644 index 0000000..4db5e14 --- /dev/null +++ b/content/docs/campaigns/hosting/meta.json @@ -0,0 +1 @@ +{"title":"Hosting","pages":["index","cloudflare-pages","netlify","vercel"]} diff --git a/content/docs/campaigns/hosting/netlify.mdx b/content/docs/campaigns/hosting/netlify.mdx new file mode 100644 index 0000000..ee25f89 --- /dev/null +++ b/content/docs/campaigns/hosting/netlify.mdx @@ -0,0 +1,25 @@ +--- +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] +--- + +## Connect the repository + +Import an existing project from Git and select the repository and production branch. Set the base directory to the folder containing the build package.json. For a standard Page Kit project, enter `npm run build` as the build command and `_site` as the publish directory. Match the Node version used locally. Start the deployment and check the build log for successful publication. + +## 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. + +Put a `_redirects` file in the publish directory on every build. 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/). diff --git a/content/docs/campaigns/hosting/vercel.mdx b/content/docs/campaigns/hosting/vercel.mdx new file mode 100644 index 0000000..bfb844b --- /dev/null +++ b/content/docs/campaigns/hosting/vercel.mdx @@ -0,0 +1,25 @@ +--- +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] +--- + +## Connect the repository + +Use a plan that permits commercial campaigns. [Hobby is for personal, non-commercial use](https://vercel.com/docs/plans/hobby). Import the Git repository as a new project and choose framework preset **Other**. Set the root directory to the folder containing the build package.json. For a standard Page Kit project, enter `npm run build` as the build command and `_site` as the output directory. Match the Node version used locally. Start the deployment and check the build log for successful publication. + +## 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). diff --git a/content/docs/campaigns/index.mdx b/content/docs/campaigns/index.mdx index abafa5a..e76cc2c 100644 --- a/content/docs/campaigns/index.mdx +++ b/content/docs/campaigns/index.mdx @@ -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: - -- **Build command:** `npm run build` -- **Publish directory:** `_site` - -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. +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. ### Netlify -[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 Netlify](/docs/campaigns/hosting/netlify). ### Cloudflare Pages -[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 Cloudflare Pages](/docs/campaigns/hosting/cloudflare-pages). + +### Vercel + +[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). diff --git a/content/docs/campaigns/meta.json b/content/docs/campaigns/meta.json index 8adb683..332d503 100644 --- a/content/docs/campaigns/meta.json +++ b/content/docs/campaigns/meta.json @@ -8,6 +8,7 @@ "index", "templates", "page-kit", + "hosting", "tracking", "[Playground](/playground)", "---Cart SDK---", diff --git a/content/docs/campaigns/page-kit.mdx b/content/docs/campaigns/page-kit.mdx index b68f7df..63f3026 100644 --- a/content/docs/campaigns/page-kit.mdx +++ b/content/docs/campaigns/page-kit.mdx @@ -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 Pages where you want a custom value such as `staging`: ```bash CPK_ENV=staging npm run build From d43b4037961c6471fd6550fe94ad2952b7bca219 Mon Sep 17 00:00:00 2001 From: Devin Michael Date: Wed, 18 Nov 2026 10:09:05 +0700 Subject: [PATCH 2/7] Keep campaign redirect rules in source control --- content/docs/campaigns/hosting/cloudflare-pages.mdx | 2 +- content/docs/campaigns/hosting/index.mdx | 2 +- content/docs/campaigns/hosting/netlify.mdx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content/docs/campaigns/hosting/cloudflare-pages.mdx b/content/docs/campaigns/hosting/cloudflare-pages.mdx index 80863f9..5c88b95 100644 --- a/content/docs/campaigns/hosting/cloudflare-pages.mdx +++ b/content/docs/campaigns/hosting/cloudflare-pages.mdx @@ -16,7 +16,7 @@ Push a branch and open its preview deployment. For repeat QA use the branch alia Under **Custom domains**, add the campaign subdomain first. Follow the DNS instructions for that hostname and wait for activation. -Include a `_redirects` file in the final `_site/` output. For a campaign subdomain whose root should send visitors to the storefront, use the rule `/ https://shop.example.com/ 301`, replacing the destination. Keep campaign paths outside that rule. +Commit `_redirects` in the build directory. After `npm run build`, have the host run `cp _redirects _site/_redirects` so each deployment includes the rules. For a campaign subdomain whose root should send visitors to the storefront, use the rule `/ https://shop.example.com/ 301`, replacing the destination. Keep campaign paths outside that rule. ## Release and rollback diff --git a/content/docs/campaigns/hosting/index.mdx b/content/docs/campaigns/hosting/index.mdx index 4c6ee4f..59aa00a 100644 --- a/content/docs/campaigns/hosting/index.mdx +++ b/content/docs/campaigns/hosting/index.mdx @@ -4,7 +4,7 @@ description: Publish Page Kit output and verify the preview and live campaign do audience: [developer] --- -Choose [Cloudflare Pages](/docs/campaigns/hosting/cloudflare-pages), [Netlify](/docs/campaigns/hosting/netlify), or [Vercel](/docs/campaigns/hosting/vercel). The recipes assume a Page Kit project. For an existing custom build, use the repository’s own build command, working directory and output folder. +Choose [Cloudflare Pages](/docs/campaigns/hosting/cloudflare-pages), [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 diff --git a/content/docs/campaigns/hosting/netlify.mdx b/content/docs/campaigns/hosting/netlify.mdx index ee25f89..c6f7946 100644 --- a/content/docs/campaigns/hosting/netlify.mdx +++ b/content/docs/campaigns/hosting/netlify.mdx @@ -16,7 +16,7 @@ Open a pull request targeting the production branch. Follow the Netlify Deploy P In Domain management, add the campaign hostname as a production domain. Apply the DNS record Netlify shows and check certificate provisioning. -Put a `_redirects` file in the publish directory on every build. 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` in the build directory. After `npm run build`, have the host run `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 From 3a518f845e63f6919a745de82d16924958858de9 Mon Sep 17 00:00:00 2001 From: Devin Michael Date: Wed, 18 Nov 2026 12:00:52 +0700 Subject: [PATCH 3/7] Distinguish Workers from the Pages dashboard setup --- content/docs/campaigns/hosting/cloudflare-pages.mdx | 8 +++++++- content/docs/campaigns/hosting/index.mdx | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/content/docs/campaigns/hosting/cloudflare-pages.mdx b/content/docs/campaigns/hosting/cloudflare-pages.mdx index 5c88b95..29756b3 100644 --- a/content/docs/campaigns/hosting/cloudflare-pages.mdx +++ b/content/docs/campaigns/hosting/cloudflare-pages.mdx @@ -4,9 +4,15 @@ description: Connect a Page Kit repository, verify a branch preview and configur audience: [developer] --- +Cloudflare recommends Workers for new projects. A Worker can serve the Page Kit build as static assets. Use the steps below when your team has chosen Pages. See [Cloudflare’s platform guidance](https://developers.cloudflare.com/pages/get-started/) and [Workers Static Assets](https://developers.cloudflare.com/workers/static-assets/). + ## Connect the repository -In Workers & Pages, create a **Pages** project, connect Git and select the campaign repository. Select the production branch and framework preset **None**. Set the root directory to the folder containing the build package.json. For a standard Page Kit project, enter `npm run build` as the build command and `_site` as the output directory. Match the Node version used locally. Start the deployment and check the build log for successful publication. +1. Open **Workers & Pages** in the Cloudflare dashboard and select **Create application**. Choose **Pages**. +2. Choose the Git import option. Cloudflare’s [static HTML guide](https://developers.cloudflare.com/pages/framework-guides/deploy-anything/) calls it **Import an existing Git repository**. Its [Git integration guide](https://developers.cloudflare.com/pages/get-started/git-integration/) calls it **Connect to Git**. +3. Authorize access to the campaign repository, select it and choose **Begin setup**. +4. Select your production branch. For a standard Page Kit project, leave the framework preset unset, enter `npm run build` under **Build command** and `_site` under **Build output directory**. The root directory defaults to the repository root. For a nested project, set **Root directory (advanced) → Path** to the folder containing the build’s `package.json`. Match the Node version used locally. +5. Choose **Save and Deploy**. After the build succeeds, open the assigned `pages.dev` hostname at the campaign’s landing path. ## Review a branch preview diff --git a/content/docs/campaigns/hosting/index.mdx b/content/docs/campaigns/hosting/index.mdx index 59aa00a..d3015af 100644 --- a/content/docs/campaigns/hosting/index.mdx +++ b/content/docs/campaigns/hosting/index.mdx @@ -4,7 +4,7 @@ description: Publish Page Kit output and verify the preview and live campaign do audience: [developer] --- -Choose [Cloudflare Pages](/docs/campaigns/hosting/cloudflare-pages), [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. +Choose [Cloudflare Pages](/docs/campaigns/hosting/cloudflare-pages), [Netlify](/docs/campaigns/hosting/netlify), or [Vercel](/docs/campaigns/hosting/vercel). For new Cloudflare projects, Cloudflare recommends [Workers with static assets](https://developers.cloudflare.com/pages/get-started/). 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 29c109653a9ef172ad142aea09eefdf04c9254be Mon Sep 17 00:00:00 2001 From: Devin Michael Date: Wed, 18 Nov 2026 12:10:57 +0700 Subject: [PATCH 4/7] Use the GitHub-connected Cloudflare Workers workflow for new campaigns --- .../campaigns/hosting/cloudflare-pages.mdx | 31 ---------------- .../campaigns/hosting/cloudflare-workers.mdx | 35 +++++++++++++++++++ content/docs/campaigns/hosting/index.mdx | 2 +- content/docs/campaigns/hosting/meta.json | 2 +- content/docs/campaigns/index.mdx | 6 ++-- content/docs/campaigns/page-kit.mdx | 4 +-- 6 files changed, 42 insertions(+), 38 deletions(-) delete mode 100644 content/docs/campaigns/hosting/cloudflare-pages.mdx create mode 100644 content/docs/campaigns/hosting/cloudflare-workers.mdx diff --git a/content/docs/campaigns/hosting/cloudflare-pages.mdx b/content/docs/campaigns/hosting/cloudflare-pages.mdx deleted file mode 100644 index 29756b3..0000000 --- a/content/docs/campaigns/hosting/cloudflare-pages.mdx +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: Deploy a campaign to Cloudflare Pages -description: Connect a Page Kit repository, verify a branch preview and configure a campaign domain on Cloudflare Pages. -audience: [developer] ---- - -Cloudflare recommends Workers for new projects. A Worker can serve the Page Kit build as static assets. Use the steps below when your team has chosen Pages. See [Cloudflare’s platform guidance](https://developers.cloudflare.com/pages/get-started/) and [Workers Static Assets](https://developers.cloudflare.com/workers/static-assets/). - -## Connect the repository - -1. Open **Workers & Pages** in the Cloudflare dashboard and select **Create application**. Choose **Pages**. -2. Choose the Git import option. Cloudflare’s [static HTML guide](https://developers.cloudflare.com/pages/framework-guides/deploy-anything/) calls it **Import an existing Git repository**. Its [Git integration guide](https://developers.cloudflare.com/pages/get-started/git-integration/) calls it **Connect to Git**. -3. Authorize access to the campaign repository, select it and choose **Begin setup**. -4. Select your production branch. For a standard Page Kit project, leave the framework preset unset, enter `npm run build` under **Build command** and `_site` under **Build output directory**. The root directory defaults to the repository root. For a nested project, set **Root directory (advanced) → Path** to the folder containing the build’s `package.json`. Match the Node version used locally. -5. Choose **Save and Deploy**. After the build succeeds, open the assigned `pages.dev` hostname at the campaign’s landing path. - -## Review a branch preview - -Push a branch and open its preview deployment. For repeat QA use the branch alias shown by Pages. 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 **Custom domains**, add the campaign subdomain first. Follow the DNS instructions for that hostname and wait for activation. - -Commit `_redirects` in the build directory. After `npm run build`, have the host run `cp _redirects _site/_redirects` so each deployment includes the rules. For a campaign subdomain whose root should send visitors to the storefront, use the rule `/ https://shop.example.com/ 301`, replacing the destination. Keep campaign paths outside that rule. - -## 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. In Deployments, select the known-good production deployment and roll back to it. - -See the [Cloudflare Pages deployment documentation](https://developers.cloudflare.com/pages/configuration/preview-deployments/). diff --git a/content/docs/campaigns/hosting/cloudflare-workers.mdx b/content/docs/campaigns/hosting/cloudflare-workers.mdx new file mode 100644 index 0000000..87b73fc --- /dev/null +++ b/content/docs/campaigns/hosting/cloudflare-workers.mdx @@ -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. diff --git a/content/docs/campaigns/hosting/index.mdx b/content/docs/campaigns/hosting/index.mdx index d3015af..1ca6c7c 100644 --- a/content/docs/campaigns/hosting/index.mdx +++ b/content/docs/campaigns/hosting/index.mdx @@ -4,7 +4,7 @@ description: Publish Page Kit output and verify the preview and live campaign do audience: [developer] --- -Choose [Cloudflare Pages](/docs/campaigns/hosting/cloudflare-pages), [Netlify](/docs/campaigns/hosting/netlify), or [Vercel](/docs/campaigns/hosting/vercel). For new Cloudflare projects, Cloudflare recommends [Workers with static assets](https://developers.cloudflare.com/pages/get-started/). 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. +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 diff --git a/content/docs/campaigns/hosting/meta.json b/content/docs/campaigns/hosting/meta.json index 4db5e14..1d32578 100644 --- a/content/docs/campaigns/hosting/meta.json +++ b/content/docs/campaigns/hosting/meta.json @@ -1 +1 @@ -{"title":"Hosting","pages":["index","cloudflare-pages","netlify","vercel"]} +{"title":"Hosting","pages":["index","cloudflare-workers","netlify","vercel"]} diff --git a/content/docs/campaigns/index.mdx b/content/docs/campaigns/index.mdx index e76cc2c..9f79b8d 100644 --- a/content/docs/campaigns/index.mdx +++ b/content/docs/campaigns/index.mdx @@ -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. -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 @@ -297,9 +297,9 @@ Choose a host and follow the [campaign hosting guide](/docs/campaigns/hosting) t [Deploy a campaign to Netlify](/docs/campaigns/hosting/netlify). -### Cloudflare Pages +### Cloudflare Workers -[Deploy a campaign to Cloudflare Pages](/docs/campaigns/hosting/cloudflare-pages). +[Deploy a campaign to Cloudflare Workers](/docs/campaigns/hosting/cloudflare-workers). ### Vercel diff --git a/content/docs/campaigns/page-kit.mdx b/content/docs/campaigns/page-kit.mdx index 63f3026..ade2580 100644 --- a/content/docs/campaigns/page-kit.mdx +++ b/content/docs/campaigns/page-kit.mdx @@ -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 Cloudflare 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 @@ -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. From 33a7606aae7211e14ba325b7adc13a0fbe186f2e Mon Sep 17 00:00:00 2001 From: Devin Michael Date: Wed, 18 Nov 2026 12:13:45 +0700 Subject: [PATCH 5/7] Specify GitHub import and Page Kit build settings on Netlify and Vercel --- content/docs/campaigns/hosting/netlify.mdx | 9 +++++++-- content/docs/campaigns/hosting/vercel.mdx | 11 +++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/content/docs/campaigns/hosting/netlify.mdx b/content/docs/campaigns/hosting/netlify.mdx index c6f7946..9f9ca8a 100644 --- a/content/docs/campaigns/hosting/netlify.mdx +++ b/content/docs/campaigns/hosting/netlify.mdx @@ -4,9 +4,14 @@ description: Connect a Page Kit repository, verify a branch preview and configur audience: [developer] --- -## Connect the repository +## Import the campaign from GitHub -Import an existing project from Git and select the repository and production branch. Set the base directory to the folder containing the build package.json. For a standard Page Kit project, enter `npm run build` as the build command and `_site` as the publish directory. Match the Node version used locally. Start the deployment and check the build log for successful publication. +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` 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 diff --git a/content/docs/campaigns/hosting/vercel.mdx b/content/docs/campaigns/hosting/vercel.mdx index bfb844b..b648b8d 100644 --- a/content/docs/campaigns/hosting/vercel.mdx +++ b/content/docs/campaigns/hosting/vercel.mdx @@ -4,9 +4,16 @@ description: Connect a Page Kit repository, verify a branch preview and configur audience: [developer] --- -## Connect the repository +## Import the campaign from GitHub -Use a plan that permits commercial campaigns. [Hobby is for personal, non-commercial use](https://vercel.com/docs/plans/hobby). Import the Git repository as a new project and choose framework preset **Other**. Set the root directory to the folder containing the build package.json. For a standard Page Kit project, enter `npm run build` as the build command and `_site` as the output directory. Match the Node version used locally. Start the deployment and check the build log for successful publication. +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 From 1dfef14af5109dc96d6d81d32acdada499d01d20 Mon Sep 17 00:00:00 2001 From: Devin Michael Date: Thu, 26 Nov 2026 12:33:59 +0700 Subject: [PATCH 6/7] Netlify: commit _redirects at the project root and copy it in the build command --- content/docs/campaigns/hosting/netlify.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/campaigns/hosting/netlify.mdx b/content/docs/campaigns/hosting/netlify.mdx index 9f9ca8a..5d97e6b 100644 --- a/content/docs/campaigns/hosting/netlify.mdx +++ b/content/docs/campaigns/hosting/netlify.mdx @@ -21,7 +21,7 @@ Open a pull request targeting the production branch. Follow the Netlify Deploy P In Domain management, add the campaign hostname as a production domain. Apply the DNS record Netlify shows and check certificate provisioning. -Commit `_redirects` in the build directory. After `npm run build`, have the host run `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. +Commit `_redirects` alongside package.json and set the 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 From a71bae98bfee7b4d19b7f5b8555bfee7d79c107b Mon Sep 17 00:00:00 2001 From: Devin Michael Date: Thu, 26 Nov 2026 17:30:55 +0700 Subject: [PATCH 7/7] Netlify: set the redirect copy in the import step's build command --- content/docs/campaigns/hosting/netlify.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/docs/campaigns/hosting/netlify.mdx b/content/docs/campaigns/hosting/netlify.mdx index 5d97e6b..d6c6f58 100644 --- a/content/docs/campaigns/hosting/netlify.mdx +++ b/content/docs/campaigns/hosting/netlify.mdx @@ -8,7 +8,7 @@ audience: [developer] 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` 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. +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/). @@ -21,7 +21,7 @@ Open a pull request targeting the production branch. Follow the Netlify Deploy P 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 and set the 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. +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. ## Release and rollback