This is an example supporting this tutorial.
-
Set
NPM_TOKENenvironment variable to the value provided by your Uniform rep. This will be needed to be able to runnpm installsince this project is using some private packages. -
Uniform project with at least 1 signal or enrichment created. Publish from the Personalization section at least once.
-
The latest version of Wrangler CLI installed:
npm i @cloudflare/wrangler -g
-
An origin site is rendering with "edge" output type and available for the worker to connect to. This could be either a server-side rendered site, or a statically generated site, the important part is that
UniformContextmust haveoutputTypeset toedge, example from our React-based apps (similar setup needed for Vue.js apps):<UniformContext ... outputType={"edge"} > ... </UniformContext>
-
Open
wrangler.tomland setORIGIN_URLto the value of either your server (if you are doing SSR), or your static origin in case of SSG. This could be any origin, for example, Azure Blob Storage, S3, etc., make sure it starts withhttps://.[vars] ORIGIN_URL = "https://yoursloworigin.com" -
Set the worker name and account_id (can be retrieved from your Cloudflare panel)
name = "your-worker-name" account_id = "abc"
-
Update your .env file according to your Uniform project settings:
UNIFORM_API_KEY=your-project-api-key UNIFORM_PROJECT_ID=your-project-id
-
Run this command to download Uniform manifest with personalization configuration:
npm run uniform:manifest
-
Run the following command for local worker to start:
wrangler dev
-
Open http://localhost:8787 after it is successful
Run this command to publish the worker:
wrangler publish