Skip to main content

Deploying a Weaverse Theme to Cloudflare Workers

This is a migration, not a supported preset. Weaverse themes (Pilot, Naturelle) ship configured for Shopify Oxygen — the Oxygen Vite plugin, the Oxygen request handler, and Oxygen worker types. There is no Cloudflare plugin, wrangler config, Cloudflare worker entry, or cf-* script in the theme. Everything on this page is something you add yourself.For production storefronts, use Shopify Oxygen. Only take this path if you have a concrete reason to host on Cloudflare, and budget time to validate the result end to end.

What your theme ships with today

Before changing anything, it helps to see exactly what you are migrating away from. In the current Pilot theme: Nothing below is pre-configured. Treat each step as a change you are making to your own fork.

Prerequisites

  • Node.js: >=22.12.0 (this is the engines.node requirement of the current Pilot theme)
  • Cloudflare account: sign up at cloudflare.com
  • Shopify store: active store with Storefront API access
  • Weaverse project: a configured project ID for your storefront
  • A working Oxygen build first — run npm run build and confirm it succeeds before you start migrating

Quick Flow

1

Add the Cloudflare dependencies

npm i -D wrangler @cloudflare/vite-plugin
2

Swap the Oxygen Vite plugin for the Cloudflare plugin

Edit vite.config.ts.
3

Create wrangler.json

Point main at your worker entry and enable nodejs_compat.
4

Add your own npm scripts

deploy, cf-dev, cf-typegen, check — none of these exist yet.
5

Upload secrets and deploy

npx wrangler secret bulk .dev.vars then npx wrangler deploy.
The rest of this page expands each step.

1. Install the Cloudflare toolchain

@cloudflare/vite-plugin builds your app for the workerd runtime as Cloudflare runs it. wrangler is the CLI used to configure, preview, and deploy the worker.

2. Update vite.config.ts

Your theme currently registers the Oxygen plugin. Replace it with the Cloudflare plugin — running both is not supported, since each one owns the SSR environment.
vite.config.ts
Keep assetsInlineLimit: 0. Pilot sets this so no asset is inlined as a data URI, which keeps the storefront compatible with a strict Content-Security-Policy. See Content Security Policy.
Removing oxygen() also removes the local Oxygen preview that npm run dev and npm run preview rely on. Decide up front whether you are keeping an Oxygen path for local development or moving entirely to wrangler dev.

3. Review your worker entry

server.ts already exports a module-format worker — a default object with an async fetch(request, env, executionContext) method — which is the shape Cloudflare Workers expects. What is not portable is the Oxygen-specific plumbing around it:
  • createRequestHandler is imported from @shopify/hydrogen/oxygen
  • env.d.ts pulls worker globals from @shopify/oxygen-workers-types
  • createHydrogenRouterContext builds the Hydrogen context from Oxygen’s env binding shape
Shopify does not publish a Cloudflare Workers entry for Hydrogen. You will need to verify that the Oxygen request handler, session storage, and caching behave correctly on Cloudflare, and adjust server.ts if they do not. Test this before pointing production traffic at it.

4. Create wrangler.json

This file does not exist in the theme — create it in the project root:
wrangler.json
If your Cloudflare login has access to multiple accounts, add "account_id": "<your-cloudflare-account-id>" so Wrangler does not prompt. Find it in the Cloudflare Dashboard under Workers & Pages → Overview (right sidebar).

5. Configure environment variables

Wrangler reads local development values from .dev.vars. Create one from your existing .env values:
.dev.vars
Add any optional variables your theme uses (JUDGEME_PRIVATE_API_TOKEN, KLAVIYO_PRIVATE_API_TOKEN, PUBLIC_GOOGLE_GTM_ID, and so on) — see .env.example in your theme for the authoritative list. Upload them as Worker secrets:
Setting NODE_ENV=production prevents Hydrogen from injecting its development-only virtual routes into the production build.
Add .dev.vars to .gitignore. The theme already ignores .env and .wrangler/, but not .dev.vars — add it yourself.

6. Add npm scripts

None of these scripts exist in the theme. Add the ones you need to package.json:
package.json

7. Deploy

Wrangler prints the live URL on success, typically https://your-project-name.<subdomain>.workers.dev.

Post-Deployment

Stream logs

Keep this running during your first smoke test so runtime errors surface immediately.

Custom domain

  1. Open the Cloudflare Dashboard
  2. Workers & Pages → select your worker
  3. Settings → Domains & Routes
  4. Add your domain and configure routes
See also Custom Domain and DNS.

Git-connected builds

  1. Workers & Pages → your worker → Settings → Builds
  2. Connect a Git repository and authorize access
  3. Select the repository and branch
  4. Build command npm run build, output directory dist

Rollback

A rollback shifts all traffic immediately. Verify the target deployment is healthy first.

Troubleshooting

Build fails after removing oxygen() npm run dev, npm run preview, and npm run start all go through the Shopify CLI’s Oxygen sandbox. Once the Oxygen plugin is gone, use npm run cf-dev instead. nodejs_compat errors at runtime Confirm the flag is in wrangler.json and that compatibility_date is recent enough for the Node compatibility mode your dependencies need. Missing environment variables in production .dev.vars is local-only. Values reach production only after npx wrangler secret bulk .dev.vars, or by setting them in the dashboard. Names are case-sensitive. Weaverse Studio preview does not connect Check WEAVERSE_PROJECT_ID and WEAVERSE_HOST are present as Worker secrets, and that the deployed URL is registered on your Weaverse project. See Preview Errors. Session or cache behaves differently than on Oxygen Expected — this is the least-validated part of the migration. Compare against an Oxygen deployment before going live.

Additional Resources