Unapproved prototype. Not approved for use in a live service.

Make a prototype

A step-by-step guide to building a Defra prototype. You do not need to be able to code, and you do not need to have used a terminal before.

A prototype is for showing ideas and testing them with users. It is not a real service. Never put real personal data into one.

Before you start

You need two things installed on your computer. Both are free.

1. Node.js

This runs the prototype on your machine. Go to nodejs.org and download the version marked LTS. Open the file you downloaded and follow the instructions.

2. Git

This saves versions of your work and lets you share it. On a Mac it is usually already installed. On Windows, download it from git-scm.com.

Open a terminal

A terminal is a window where you type commands instead of clicking. You will copy and paste into it — you do not need to memorise anything.

  • Mac — press Command and Space, type Terminal, press Enter
  • Windows — press the Start button, type PowerShell, press Enter

To check Node.js installed correctly, type this and press Enter:

node --version

You should see a number like v22.20.0. If the number is lower than 20, or you see an error, install Node.js again from the link above and then close and reopen the terminal.

Create the prototype

Run this. You do not need to be in any particular folder, and you do not need to make one first — every prototype is kept together in a Defra prototypes folder in your home folder.

npx defra-create-prototype

If it asks Ok to proceed? (y), type y and press Enter. Then it asks you two questions.

What are you prototyping?
Write it as you would say it — for example Register a water abstraction. This becomes the name shown in the header, and a tidied-up version of it becomes the folder name.
Will this service be on a service.gov.uk address?
Press Enter for no, which is the usual answer for Defra services. This decides the header, footer and typeface — see which branding to use. If you are not sure, ask before changing it later: it is a licensing question, not a design preference.

Then it takes a few minutes and prints a lot of text, which is normal. At the end it tells you exactly where your prototype is and the two lines to copy to start it.

If that command does not work

You need access to the Defra GitHub organisation for it to fetch the code. If it cannot, download the code first and run it from there instead:

git clone https://github.com/defra-design/defra-frontend.git
node defra-frontend/packages/create-prototype/bin/create.mjs my-service

Both routes produce exactly the same prototype.

It creates the folder and sets up everything for you:

  • the GOV.UK Prototype Kit
  • Defra styling, so your pages look like a Defra service
  • Defra page templates
  • a README explaining how to run it, so you do not have to remember
  • a first saved version, so your work is protected from the start

Start it

Copy the two lines the command printed. They look like this, with your own prototype's name:

cd "~/Defra prototypes/register-a-water-abstraction"
npm run dev

cd means "change directory" — it moves the terminal into your prototype's folder. You need to be in that folder for npm run dev to work, which is why the two lines go together.

Open http://localhost:3000 in your browser. You should see your prototype.

It is npm run dev, not npm start. Both appear in your prototype's package.json, which makes npm start an easy guess, but that one is meant for hosting services — run on your own machine it does not watch your files, so your changes will not appear.

Leave the terminal open while you work — it is running the prototype. To stop it, click the terminal and press Ctrl and C together.

Make your first page

Go to http://localhost:3000/manage-prototype and choose Create a new page. Pick one of the Defra templates:

  • Defra start page — the first page of a service
  • Defra question page — one question, as the service pattern requires
  • Defra check answers page — the summary before submitting

Pages live in the app/views folder and are ordinary HTML. A file at app/views/apply/name.html appears at /apply/name. Open them in any text editor — Visual Studio Code is free and widely used.

Getting help from an assistant

Your prototype is already set up to work with Visual Studio Code and GitHub Copilot. Open the prototype folder in VS Code and ask Copilot for what you want in plain English — it can see what the Defra design system contains and will use the right components.

It can:

  • tell you which components exist and what they do
  • make a page from one of the Defra templates
  • start your prototype so you can look at it
  • check your pages for accessibility problems
  • freeze a round of research so you can come back to it
  • put your prototype on GitHub

There is nothing to set up. If your prototype was made before this existed, run the update command and it will be added.

What it will not do

It will not put your prototype on the web. It can push your work to GitHub, but publishing it somewhere people can reach still needs a hosting service — see Publishing your prototype.

It will not tell you your prototype is accessible. The accessibility check finds problems in the markup, which is a minority of accessibility, and it will say so. A prototype with no errors has not been accessibility tested.

It can be wrong. It writes real files in your prototype, so look at what changed before you rely on it, and keep your work on GitHub so you can go back.

Putting your prototype on GitHub

Put your prototype on GitHub so it is backed up, so colleagues can see it, and so it can be handed over. Your prototype is already saving versions locally — this puts those versions somewhere safe.

1. Create an empty repository

Go to github.com/new and:

  • choose the Defra organisation as the owner, if you can
  • name it the same as your folder
  • leave it private unless your team has agreed otherwise
  • do not tick "Add a README" — you already have one

2. Connect and upload

GitHub shows you a page of commands. Use the two under "…or push an existing repository". They look like this, with your own names in place of DEFRA and my-service:

git remote add origin https://github.com/DEFRA/my-service.git
git push -u origin main

3. Save your work as you go

Each time you finish something worth keeping, run these three lines. The message should say what you changed.

git add -A
git commit -m "Add the eligibility questions"
git push
Before pushing, check you have not written anything real into your pages — names, addresses, case references. A private repository is not a safe place for personal data, and once something is pushed it stays in the history even if you delete it later.

Sharing with users for research

localhost only works on your own machine, so you cannot send that address to anyone. To test with users remotely the prototype needs hosting somewhere, which needs a password on it.

Hosting is a team decision and depends on what your programme already uses, so ask your technical lead rather than setting one up alone. See Publishing your prototype below for the options and the two settings a password needs.

Finding your prototypes

To see everything you have made, with the command to start each one:

npx defra-create-prototype --dashboard

This opens a page listing every prototype in your Defra prototypes folder. For any that have two versions, it also shows which pages are different between them — handy before a research session, because it tells you where the comparison is actually worth making.

If you have prototypes from before, kept somewhere else, point it at them:

npx defra-create-prototype --dashboard --dir ~/Documents/GitHub

It only reads that folder. The page itself is always written into your Defra prototypes folder, so nothing is added to wherever you are looking.

Comparing two versions in research

If you want to show someone how a service works today and how it might work, you can split your prototype into two versions. Run this from inside your prototype folder:

npx defra-create-prototype --variants

Your pages move into a current folder, and a copy of them becomes a future folder. You then change the future one and leave the current one alone.

localhost:3000/current/
How it works today
localhost:3000/future/
How it might work
localhost:3000
A page linking to both, for you rather than for participants

Both versions run from the same npm run dev, in two browser tabs if you want them side by side. They also share the same header, footer and styles, so if you fix something that both have in common, you only fix it once.

Each prototype also has its own web address, so you can have two different prototypes open at the same time without them fighting over the same one. You do not need to do anything — npm run dev uses the right one, and it tells you what it is. Prototypes made before this all used localhost:3000; running --update on one gives it its own.

Before you run it, save your work with git. This command moves your pages and edits the links inside them, and a clean starting point is what lets you undo it with git checkout . if it gets something wrong. It will refuse to run until you have.

Check a couple of journeys in each version before you rely on it in a session — particularly any links you typed by hand.

Updating an existing prototype

Your prototype stays on the version of Defra Frontend it was made with, so fixes and new components do not reach it on their own. To bring it up to date, run this from inside your prototype folder:

npx defra-create-prototype --update

It reports the version before and after, and tells you if your prototype contains workarounds that are no longer needed. Restart with npm run dev afterwards.

Nothing else in your prototype is touched — your pages, your layout and your data stay exactly as they are.

If you made your prototype before October 2026

Early prototypes kept their own copy of Defra Frontend in a vendor folder, because the package had not been published yet. The update command moves yours across to the published package and deletes that folder.

You will see a short list of what it changed. Commit those changes along with your own work. Nothing you have built is affected.

Publishing your prototype

A prototype is a small web application, not a set of files, so it needs somewhere that can run it. That rules out the simplest options and is worth knowing before you promise a link to anyone.

Ask your technical lead first. Your programme may already pay for somewhere to put these, and that is both cheaper and easier than signing up for an account yourself.

If not, the Prototype Kit names three services that publish automatically every time you push to GitHub:

Railway
Connects to a GitHub repository and redeploys on push.
Render
The same arrangement.
Heroku
Also works, and is what Defra teams have mostly used — but the kit marks it “requires payment”, and it has had no free tier since 2022. Worth comparing before defaulting to it.

GitHub Pages and Netlify will not work. The kit says so itself: it “does not run on ‘static’ hosting services”. A prototype is a small Node application, not a folder of files — it remembers what someone typed, and that needs a server. There is no export that gets around it, and a static copy could not be password-protected either.

Setting the password

Wherever you publish, set two environment variables. Your hosting service may call them “config vars” or just “variables”.

NODE_ENV
production
PASSWORD
Whatever password you want to share with participants

Both, or neither works. The kit only asks for a password when NODE_ENV is production. Set PASSWORD on its own and it is ignored completely — your prototype is published, looks right, and anyone who finds the address can walk straight in.

Do not take it on trust. Check, with the command below.

Check it is actually protected

After publishing, run this with your prototype's address:

npx defra-create-prototype --check https://my-service.up.railway.app

It asks your published prototype whether it wants a password, and tells you plainly. If it says NOT PROTECTED, the fix is almost always the missing NODE_ENV — it will say so.

Worth doing every time you change the hosting settings, and before you send the address to anyone. A prototype that is published and open looks exactly like one that is published and protected.

A prototype looks like a real service, and someone who finds one without context has no way of knowing it is not. Never put real personal data in a published prototype.

If something goes wrong

command not found: npx
Node.js is not installed, or the terminal was open before you installed it. Close the terminal, open a new one, and try again.
EADDRINUSE or "port already in use"
A prototype is already running in another terminal window. Find it and press Ctrl and C, or close that window.
The page looks unstyled
Stop the prototype with Ctrl and C, then run npm run dev again. The styles are rebuilt on start.
A change does not appear
Save the file, then refresh the browser. If it still does not appear, check you edited a file inside app/views.

Which layout to use

Your prototype uses the Defra layout: a Defra header and footer, and system fonts rather than the GOV.UK typeface. That is not a style preference — GDS Transport and the GOV.UK header and footer are licensed for services on *.service.gov.uk only.

If your service will be on *.service.gov.uk, change the first line of app/views/layouts/main.html to extend "govuk-prototype-kit/layouts/govuk-branded.njk" instead. If you are not sure which applies, ask before you show the prototype to anyone outside the team.