How to let clients edit a React and Vite site
By Yash Garg · · 6 min read
To let clients edit a React and Vite site, move the words they will change into JSON or TypeScript data modules, give images a fixed home, and connect the repository to a host that rebuilds on every push. Then pick how the client edits those files: GitHub's web editor, a Git-based CMS or a visual editor that commits for them. A typical marketing site needs no database and no headless CMS.
If your site runs on Next.js instead, the guide on client edits for Next.js sites covers the same ground for that framework.
Step 1: put copy in data modules
Components should render content, not contain it. Pull every sentence the client might change into a data module and import it where it is used.
Vite handles this without plugins: JSON files can be directly imported, and named imports of root fields are also supported, which the docs say helps with tree-shaking. A TypeScript module that exports plain objects works the same way and adds type checking.
An example layout for a small site:
| File | Contents | Edited by |
|---|---|---|
| src/content/home.json | Hero headline, subtitle, button label | Client |
| src/content/services.json | List of services, each with a title and a short text | Client |
| src/content/contact.json | Phone, email, address, opening hours | Client |
| src/content/team.ts | Names, roles, imported photos | You |
| src/components/Hero.tsx | Layout and styling | You |
JSON or TypeScript
- JSON is the safer choice for non-developers. It holds only data, with no imports or functions to break, so image references are plain path strings.
- TypeScript lets you import images and type-check the shape of each entry, but a client who opens it sees code.
A simple rule: JSON for anything the client edits often, TypeScript for content you maintain.
Keep the shape flat and predictable. Arrays of objects with the same keys (services, testimonials, team members) are easy to edit, easy to extend and easy for an editing tool to recognise as a list.
Step 2: decide where images live
Vite gives you two places for images, and the choice matters once a client starts swapping photos.
Imported assets. Importing an image returns its public URL, and imported assets get hashed file names and can be processed by plugins for optimization. This suits logos, icons and anything you manage in code.
The public directory. Files in public are served at root path and copied to the root of the dist directory as-is, and you reference them with a root absolute path. For client-managed photos this is usually simpler: a JSON entry holds a path such as /images/team/ana.jpg, and the client uploads a file to that location.
Because public files keep their names, give a replacement image a new file name and update the path, rather than overwriting the old file under the same name. Agree on a size guideline (for example, under 300 KB for a hero photo) and one folder per section.
Step 3: keep env vars out of content
Environment variables are configuration, not content. Vite's docs state that variables prefixed with VITE_ will be exposed in client-side source code after bundling, and warn that those values are bundled into your code at build time, so they should never hold API keys.
Two rules follow from that:
- Business details go in data modules. A phone number, an address or opening hours belong in src/content, where an edit is a normal commit. Env vars live in your host's settings, which the client should not need to touch.
- Secrets stay out of the bundle. API keys belong on a server or serverless function, as the same Vite page on env variables recommends, never in a data file or a VITE_ variable.
Step 4: build and deploy on every push
A client edit is only useful if it goes live without you. Vite's guide notes that the build output is placed at dist by default, and it describes Git-connected setups on Netlify, Vercel and Cloudflare Pages where changes to the production branch result in a production deployment and other branches get preview deployments.
Set it up once:
- Connect the repository to your host, with npm run build as the build command and dist as the output folder.
- Set the production branch, commonly main.
- Keep preview deployments on for other branches, so risky edits can be checked first.
- Push one test edit and confirm the live site updates.
Step 5: choose how the client edits
| Option | What the client sees | Setup effort | Best for |
|---|---|---|---|
| GitHub web editor | Raw JSON in the browser | Minutes | Technical clients, rare edits |
| Git-based CMS | Forms built from a config file | A config entry per field | Blogs and repeated entries |
| Visual editor | The live page, click to edit | Connect the repo, invite the client | Marketing pages, visual clients |
GitHub's web editor. GitHub lets you edit files directly on GitHub using the file editor and commit the change from the browser. The client needs a GitHub account and edits raw JSON, where one missing comma or quote breaks the build.
A Git-based CMS. TinaCMS describes itself as an open-source, Git-backed CMS where, when users make a change, a commit is made back to your Git repository. You describe each editable field in a config, so it suits collections such as posts or projects better than one-off page copy. See how a visual editor compares with TinaCMS for the trade-offs.
A visual editor. A visual editor renders the site, lets the client click text, links, images or list items, and commits each change into the source files. TurnIntoCMS works this way with React and Vite sites, as long as the content is written in JSX or in imported data files; content fetched from an API at runtime is out of its reach. The page on visual editing for React and Vite sites walks through the setup, and the comparison of client editing tools lists the alternatives.
Handoff checklist
- Client-editable copy lives in src/content, not in components
- Data modules export plain strings, numbers and arrays
- Client photos have one folder per section and a size guideline
- No secrets or API keys sit in any file the client can open
- The host rebuilds on every push to the production branch
- Preview deployments are on for other branches
- One real test edit has gone live through the chosen editor
Common mistakes
- Text hard-coded in JSX. The client can't find it, or edits markup by accident. Fix: move it into a data module before handoff.
- Business details in .env. A phone number change then needs host access. Fix: keep it in a data file and leave env vars for configuration.
- Secrets in VITE_ variables. They end up in the public bundle. Fix: call a server function that holds the key.
- Overwriting public images under the same name. Visitors may keep seeing the old photo. Fix: upload with a new file name and update the path.
- Edits straight to production with no preview. Fix: send larger changes through a branch with a preview deployment.
FAQ
Can a client edit a Vite site without a CMS?
Yes. Keep the content in JSON or TypeScript data modules and give the client GitHub's editor, a Git-based CMS or a visual editor that writes to those files.
Should content go in JSON or TypeScript files?
Use JSON for content the client edits often, since it holds only data. Use TypeScript when you need image imports or type checking and you are the main editor.
Where should images go in a Vite project?
Client-managed photos are simplest in the public folder, referenced by root paths stored in your data files. Images you manage can be imported so Vite hashes them.
Do I need a server for client edits to go live?
No. A static host connected to the repository rebuilds the site on each push, so a committed edit goes live once the build finishes.
Sources
- Features | Vite (vite.dev, checked November 18, 2026)
- Static Asset Handling | Vite (vite.dev, checked November 18, 2026)
- Env Variables and Modes | Vite (vite.dev, checked November 18, 2026)
- Deploying a Static Site | Vite (vite.dev, checked November 18, 2026)
- Editing files (docs.github.com, checked November 18, 2026)
- Get Started and learn about TinaCMS (tina.io, checked November 18, 2026)