From an empty folder to the owner's first save
This part wires the whole stack from Part 1, in the order it goes together: the Next.js project and its packages, TinaCMS in the code, the Next.js settings Cloudflare needs, a local check in Cloudflare's runtime, Tina Cloud, Cloudflare Workers Builds, and finally the live editor. Every file below is the working file from the example site, a one-page site for a logistics company, trimmed only where a pattern repeats.
Two accounts come into it, Tina Cloud and Cloudflare, plus the GitHub repository that both of them read.
1. The Next.js project and its packages
npx create-next-app@latest my-site --js --app --tailwind --eslint --no-src-dir --import-alias "@/*" --use-npm --yes
cd my-site
npm i tinacms
npm i -D @tinacms/cli @opennextjs/cloudflare wranglerNext.js 16's starter turns on cacheComponents and partialPrefetching in next.config.mjs. Both come out in step 3, since Cloudflare's runtime hangs on Cache Components.
The scripts in package.json:
{
"scripts": {
"dev": "tinacms dev -c \"next dev -p 3005\"",
"build": "tinacms build --noTelemetry && next build",
"cf:build": "opennextjs-cloudflare build",
"cf:deploy": "opennextjs-cloudflare deploy",
"build:local": "tinacms build --local --skip-cloud-checks -c \"NODE_ENV=production next build\"",
"start": "next start",
"lint": "eslint"
}
}devstarts Tina's local servers, then the Next.js dev server on port 3005, with the editor atlocalhost:3005/admin.buildis what every host runs:tinacms buildchecks the schema against Tina Cloud and generates the client, thennext buildbuilds the site.--noTelemetrykeeps the CLI's usage reports off.cf:buildandcf:deployare the Cloudflare adapter's commands, the same ones Workers Builds runs.build:localbuilds for production against the content on disk, for testing before Tina Cloud exists. TheNODE_ENV=productioninside it matters; Part 3 shows the error it prevents.
The lines to add to .gitignore:
.env*
# generated from tina/config.js on every dev and build run
/public/admin
/tina/__generated__
# Cloudflare adapter and Wrangler output
/.open-next
/.wrangler
.dev.vars*2. TinaCMS in the code
The schema: tina/config.js
The schema names every field the owner edits. The example holds the whole page in one document, one JSON file, with each section as an object field. Two sections show every pattern the rest repeat:
import { defineConfig } from "tinacms";
// The branch Tina Cloud saves to.
const branch = process.env.GITHUB_BRANCH || "main";
const textarea = { component: "textarea" };
// A heading in two tones: the title, then the part shown in the brand colour.
const heading = [
{ type: "string", name: "eyebrow", label: "Small label above" },
{ type: "string", name: "title", label: "Heading" },
{ type: "string", name: "highlight", label: "Heading, coloured part" },
];
// Label each card in a list by one of its own fields.
const listLabel = (field) => ({ itemProps: (item) => ({ label: item?.[field] }) });
export default defineConfig({
branch,
clientId: process.env.NEXT_PUBLIC_TINA_CLIENT_ID,
token: process.env.TINA_TOKEN,
build: { outputFolder: "admin", publicFolder: "public" },
// Uploads from the editor land in public/images.
media: { tina: { mediaRoot: "images", publicFolder: "public" } },
schema: {
collections: [
{
name: "page",
label: "Page",
path: "content",
format: "json",
ui: {
// One page: the editor opens it; adding and deleting stay off.
allowedActions: { create: false, delete: false },
router: () => "/",
},
fields: [
{
type: "object",
name: "hero",
label: "Hero",
fields: [
{
type: "object",
name: "slides",
label: "Slides",
list: true,
ui: listLabel("eyebrow"),
fields: [
...heading,
{ type: "string", name: "text", label: "Text", ui: textarea },
{ type: "image", name: "image", label: "Background image" },
],
},
{ type: "string", name: "primaryButton", label: "Main button" },
{ type: "string", name: "secondaryButton", label: "Second button" },
],
},
{
type: "object",
name: "about",
label: "About",
fields: [
...heading,
{ type: "string", name: "text", label: "Text", ui: textarea },
{ type: "image", name: "image", label: "Picture" },
{
type: "object",
name: "figures",
label: "Figures",
list: true,
ui: listLabel("label"),
fields: [
{ type: "string", name: "value", label: "Figure" },
{ type: "string", name: "label", label: "Label" },
{
type: "string",
name: "icon",
label: "Icon",
options: [
{ value: "truck", label: "Truck" },
{ value: "forklift", label: "Forklift" },
{ value: "genset", label: "Genset" },
{ value: "container", label: "Container" },
],
},
],
},
],
},
{
type: "object",
name: "contact",
label: "Contacts and footer",
fields: [
{ type: "string", name: "phones", label: "Phone numbers", list: true },
{ type: "string", name: "email", label: "Email" },
{ type: "string", name: "footerText", label: "Footer line", ui: textarea },
],
},
],
},
],
},
});The services, industries, process and call-to-action sections follow the same shapes: a heading, a text, and a list of cards with a name, a line and a picture.
The content file: content/home.json
{
"hero": {
"slides": [
{
"eyebrow": "Transport Services",
"title": "Cargo moved",
"highlight": "Arriving safely and on time.",
"text": "Full and part loads by road, delivered promptly and safely to their destination.",
"image": "/images/hero-transport.jpg"
}
],
"primaryButton": "Get a Quote",
"secondaryButton": "Explore Our Services"
},
"about": {
"eyebrow": "About us",
"title": "Moving cargo,",
"highlight": "powering sites.",
"figures": [
{ "value": "1200+", "label": "Trips a year", "icon": "truck" },
{ "value": "40+", "label": "Forklifts on lease", "icon": "forklift" }
]
},
"contact": {
"phones": ["+000 000 000 000"],
"email": "hello@example.com"
}
}Reading the content: app/page.js
import client from "@/tina/__generated__/client";
import Home from "@/components/home";
// One static page: the content is read at build time, and each content commit
// rebuilds the site. In development every request reads it fresh.
export default async function Page() {
const res = await client.queries.page({ relativePath: "home.json" });
return <Home data={res.data} query={res.query} variables={res.variables} />;
}Live editing: the client component
"use client";
import { useTina } from "tinacms/dist/react";
import Hero from "./hero";
import About from "./about";
import Services from "./services";
import Footer from "./footer";
export default function Home(props) {
const { data } = useTina(props);
const page = data.page;
return (
<main>
<Hero hero={page.hero} />
<About about={page.about} />
<Services services={page.services} />
<Footer contact={page.contact} />
</main>
);
}Click to edit: a section with tinaField
import Image from "next/image";
import { tinaField } from "tinacms/dist/react";
export default function Services({ services }) {
if (!services?.items?.length) return null;
return (
<section id="services">
<h2 data-tina-field={tinaField(services, "title")}>{services.title}</h2>
<p data-tina-field={tinaField(services, "text")}>{services.text}</p>
{services.items.map((item) => (
<article key={item.title} data-tina-field={tinaField(item)}>
<div data-tina-field={tinaField(item, "image")}>
<Image src={item.image} alt={item.title} width={600} height={400} />
</div>
<h3 data-tina-field={tinaField(item, "title")}>{item.title}</h3>
<p data-tina-field={tinaField(item, "text")}>{item.text}</p>
</article>
))}
</section>
);
}tinaField(item) with a card alone opens that whole card in the sidebar; tinaField(item, "title") opens one field. Part 3 explains what each piece does inside the editor.
Run npm run dev and open localhost:3005/admin: the editor works locally against the file on disk, with zero accounts, and every save shows as a change in git status. Commit tina/tina-lock.json with the code; Tina Cloud reads the schema from it.

3. Next.js settings for Cloudflare
next.config.mjs
/** @type {import('next').NextConfig} */
const nextConfig = {
// Cache Components stays off: Cloudflare's runtime hangs on it,
// and a static page needs none of it.
images: {
// Live, Tina Cloud serves the editor's pictures from its own image server.
remotePatterns: [{ protocol: "https", hostname: "assets.tina.io" }],
},
};
export default nextConfig;cacheComponentsandpartialPrefetchingfrom the starter are removed. Any"use cache"andcacheLifein pages go with them; a plain async page is prerendered at build time all the same.images.remotePatternslistsassets.tina.io. Locally, image fields hold/images/…paths; on the live site Tina Cloud returns them ashttps://assets.tina.io/<clientId>/…, and next/image answers 400 for any host missing from this list.
wrangler.jsonc
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "my-site",
"main": ".open-next/worker.js",
"compatibility_date": "2026-11-01",
"compatibility_flags": ["nodejs_compat", "global_fetch_strictly_public"],
"assets": { "directory": ".open-next/assets", "binding": "ASSETS" },
"images": { "binding": "IMAGES" }
}The name becomes the Worker's name and its address, <name>.<subdomain>.workers.dev. The ASSETS binding serves the built files, and the IMAGES binding gives next/image Cloudflare's image resizing.
open-next.config.ts
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
import staticAssetsIncrementalCache from "@opennextjs/cloudflare/overrides/incremental-cache/static-assets-incremental-cache";
// A static site: pre-built pages are served from Cloudflare's static file storage.
export default defineCloudflareConfig({ incrementalCache: staticAssetsIncrementalCache, enableCacheInterception: true });The file name is fixed: Workers Builds looks for open-next.config.ts in the project root.
4. A local check in Cloudflare's runtime
Before any account exists, the site runs locally in workerd, the runtime Cloudflare uses:
npx opennextjs-cloudflare build
npx opennextjs-cloudflare populateCache local
npx wrangler devopennextjs-cloudflare build runs the project's npm run build, and that runs tinacms build, which wants Tina Cloud's two values. For a check before Tina Cloud, point the build script at the build:local command for the run. Wrangler emulates both bindings locally, image resizing included, and prints the local address.
5. Tina Cloud, screen by screen
1. Sign up at app.tina.io, with an email or with GitHub.
2. Set up Git Authoring. Choose Act as bot: saves are committed by tinacloud-app[bot], which keeps editors' commits apart from developers'. Act as self commits as the account holder and falls back to the bot where permissions run short.
3. Co-authoring. A name and an email that Tina adds to each commit as co-author. A GitHub noreply address (<id>+<username>@users.noreply.github.com) keeps a personal email out of the repository's history. Both settings stay editable later under the account's GitHub Authoring and Co-authoring settings.

4. Authorize with GitHub. GitHub shows "TinaCloud App by Tina wants access to your GitHub account", asking to verify the identity, know which resources the account can reach and act on its behalf. Authorize, then install the app on Only select repositories and pick the site's repository.

5. Import an Existing Project. Connect Repo lists the granted repository; select it. Project Configuration asks for:
- Project Name, which editors see on the login screen;
- Site URL(s), the comma-separated origins where
/adminmay log in,http://localhost:3005for now, with the live address added after the first deploy; - Use a separate content repo, off;
- Advanced Settings, left as they are, with the Tina folder at the root and the branch
main, then Create Project.

6. Overview. The project page shows the Client ID and a four-step checklist: create the project, set up the schema, log in through your site, create a commit. After creation two of the four are ticked.

7. Tokens. Tina Cloud creates a Content (Readonly) token for all branches and a Search token. The read-only token is the build's TINA_TOKEN. The Client ID is public, since it ships in the site's code; the token stays private.

6. Cloudflare Workers Builds, screen by screen
1. Sign up at dash.cloudflare.com on the free plan and verify the email. The domain comes later, in section 7.
2. Rename the workers.dev subdomain first. Workers & Pages, under Compute in the sidebar, shows Account details on the right with Subdomain set to the sign-up email's name. The pencil renames it. Every address the account hands out carries it, so a brand name belongs there before the first deploy.

3. Create application. "Make something new" offers Connect GitHub, Connect with GitLab, Start with Hello World, Select a template and Upload your static files. Connect GitHub installs Cloudflare's GitHub app; give it the one repository.

4. Select a repository, then Next.
5. Set up your application:
- Project name, which becomes
<name>.<subdomain>.workers.dev; - Build command
npx opennextjs-cloudflare build; - Deploy command
npx opennextjs-cloudflare deploy; - Preview command
npx opennextjs-cloudflare upload, for builds of other branches; - Enable Preview builds, off to keep build minutes for the production branch;
- Protect with Cloudflare Access, off for a public site.

6. Advanced settings:
- Path
/; - API token, Create new token, which Cloudflare names after the project;
- Variables, two pairs through "+ Add variable":
NEXT_PUBLIC_TINA_CLIENT_IDwith the Client ID, andTINA_TOKENwith the read-only token and Encrypt ticked. An encrypted value stays hidden once saved. - Both are build variables, because the build command runs
npm run build, andtinacms buildreads both while building. Then Deploy.

7. The build page. After "Setting up your repository", the page shows the build settings, a stage bar (Initializing, Cloning, Installing, Building, Deploying) and a live log with Download log and Copy build log. A failed build is fixed by a commit: each push to the production branch starts the next build by itself.

A successful deploy log ends like this:
Uploaded 154 of 154 assets
Total Upload: 5032.47 KiB / gzip: 1254.29 KiB
Worker Startup Time: 35 ms
Your Worker has access to the following bindings:
env.IMAGES Images
env.ASSETS Assets
Deployed my-site triggers
https://my-site.<subdomain>.workers.dev
Success: Deploy command completed
Success! Build completed.7. The client's domain
Once the site is approved on its workers.dev address:
- Add a domain on the free plan; Cloudflare scans and copies the existing DNS records.
- Check the mail records line by line (MX, the SPF and DKIM TXT records, any autodiscover entries) so they still point at the current mail host and email keeps flowing.
- At the registrar, swap the two nameservers for the pair Cloudflare shows.
- In the Worker: Settings, Domains & Routes, add the bare domain and
wwwas Custom Domains. - To retire the workers.dev address, set
"workers_dev": falseinwrangler.jsonc.
8. Closing the loop
- In the Tina Cloud project, add the live address to Site URL(s):
http://localhost:3005, https://my-site.<subdomain>.workers.dev, plus the custom domain once it is live. - Open
https://my-site.<subdomain>.workers.dev/adminand log in with the Tina Cloud account. The live page loads in the editor, the sidebar lists the sections, and every editable element carries its dashed outline. - Edit, then Save. Within seconds a commit by
tinacloud-app[bot]with the message "TinaCMS content update" lands onmain. - That commit starts a Workers Build, and the build deploys the change.
- Invite the owner from the project's Collaborators page. The owner logs in at
/adminwith an email and password; GitHub stays out of sight. The free plan covers two editors.

9. Day to day
- Owners edit several sections and save once: one commit, one build.
- Developers pull before working, since owners' saves land on
mainas commits, and push changes in batches, since each push is a build. - Running costs: Tina Cloud free for two editors, GitHub free, Cloudflare free with 3,000 build minutes a month, and the domain's yearly renewal.
The series
- Part 2, this page: the complete wiring.
- Part 4: Deploying Next.js to Cloudflare Workers with OpenNext, with the errors that come up and their fixes.
- Part 5: Vercel vs Cloudflare for Next.js.
Sources
- Published
- Author
- Simon Booban
- Category
- Websites & Apps




