Repository navigation
Document campaign hosting on Cloudflare Workers, Netlify and Vercel #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
next-devin
wants to merge
7
commits into
main
Choose a base branch
from
docs/campaign-hosting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
590eb70
Document production hosting for NEXT campaigns
next-devin d43b403
Keep campaign redirect rules in source control
next-devin 3a518f8
Distinguish Workers from the Pages dashboard setup
next-devin 29c1096
Use the GitHub-connected Cloudflare Workers workflow for new campaigns
next-devin 33a7606
Specify GitHub import and Page Kit build settings on Netlify and Vercel
next-devin 1dfef14
Netlify: commit _redirects at the project root and copy it in the bui…
next-devin a71bae9
Netlify: set the redirect copy in the import step's build command
next-devin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"title":"Hosting","pages":["index","cloudflare-workers","netlify","vercel"]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
|
|
||
| ## 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/). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
_redirectsinto_site/, but step 3 keeps the plainnpm run buildfor any campaign that was not already known to use redirect rules. A reader who imports first and only adds_redirectswhen they reach this section still deploys withnpm 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 thenetlify.tomlbuild command) to include the copy at the point where the rules are added.