Next.js developer in Nottingham

Next.js for businesses in Nottingham, delivered remotely by one developer.

Next.js developer

My place in the WordPress community

  • I have had a wordpress.org account since 2006.
  • I contributed to WordPress core for versions 7.0 and 7.1.
  • I maintain 30 plugins on wordpress.org.
  • I organise and speak at WordCamps.
  • I have attended every WordCamp Europe from 2017 to 2026.

My WordPress.org profile

Companies House publishes the UK company register through a REST API that is free to use with a key. For a Nottingham fintech, credit tool or B2B portal that checks a customer’s company number or fills a form from register data, the API sits in the middle of the product. This page covers what the official guides require and how to build around it in Next.js. I write the integration, you decide the legal position.

Castle Wharf on the Nottingham Canal

Castle Wharf beside the Nottingham Canal. Photo: Kenny Howse, CC BY-SA 2.0, via Wikimedia Commons.

#How do I get a Companies House API key?

You need a Companies House user account. The authorisation guide says to register an application in the Developer Hub under “Your applications” as an API Key application, which allocates a unique key. That key can be sent with any GET request for a public resource.

The API uses HTTP Basic Authentication. The key is the username, and the password is ignored, so it can stay empty. The guide gives this example:

curl -XGET -u my_api_key: https://api.company-information.service.gov.uk/company/00000006

For actions that involve an end user, the guide points to OAuth 2.0 instead. A read-only lookup of public data does not need it.

#Where should the key live in a Next.js app?

On the server only. The Companies House developer guidelines list five rules:

  1. Do not embed keys in application code. Use environment variables or configuration.
  2. Do not store key files inside the source tree.
  3. Restrict each key to specific IP addresses or domains.
  4. Regenerate keys regularly, and at least with each application release.
  5. Delete obsolete keys from the registered applications page.

The Next.js docs explain why a plain environment variable is the right place. Variables without the NEXT_PUBLIC_ prefix are only available in the Node.js environment. A NEXT_PUBLIC_ variable is inlined into the JavaScript sent to the browser at build time. The Server and Client Components page lists “use API keys, tokens, and other secrets without exposing them to the client” as a reason to fetch in Server Components, and it describes the optional server-only package, which turns an accidental client import into a build error.

A small data module covers it:

// lib/companies-house.ts
import 'server-only'

const BASE = 'https://api.company-information.service.gov.uk'

export async function companyProfile(number: string) {
  const res = await fetch(`${BASE}/company/${encodeURIComponent(number)}`, {
    headers: {
      Authorization: `Basic ${Buffer.from(`${process.env.CH_API_KEY}:`).toString('base64')}`,
    },
  })
  if (res.status === 404) return null
  if (!res.ok) throw new Error(`Companies House ${res.status}`)
  return res.json()
}

The company profile endpoint is GET /company/{companyNumber}. According to its reference page it returns 200 with a companyProfile resource, 401 when unauthorised and 404 when the company is not found. Treating 404 as “no such company” and everything else as an error keeps the UI honest.

Because a key restricted to IP addresses is safer, the hosting choice matters: a host with a fixed outbound address fits that guideline better than one that rotates addresses. Check the egress behaviour of your host before you rely on it.

#What is the Companies House rate limit?

The rate limiting guide says you can make up to 600 requests within a five-minute period. Beyond that, each request receives HTTP 429 Too Many Requests until the window ends, and the count returns to 600 at the end of the five minutes. The guide mentions no rate-limit headers and gives no backoff advice. It adds two warnings:

  • Companies House may ban applications that regularly exceed the limit or try to bypass it, and it may do so without notice.
  • If your application needs a higher limit, you contact Companies House.

Six hundred in five minutes is two requests a second on average, shared by every visitor of your app. A search box that sends one request per keystroke will use that budget quickly. Two measures help: debounce on the client, and cache on the server.

#How do I cache Companies House responses in Next.js?

By default, Next.js does not cache fetch requests. The data-fetching page says identical fetch requests in one component tree are memoised during a render, and that for caching you use the use cache directive. Per the Next.js docs, use cache only works with cacheComponents: true set in next.config.ts, and the cached function has to be async.

// lib/companies-house.ts
import { cacheLife, cacheTag } from 'next/cache'

export async function cachedProfile(number: string) {
  'use cache'
  cacheLife('hours')
  cacheTag(`company-${number}`)
  return companyProfile(number)
}

The use cache page says to set cacheLife explicitly in every cached scope, and describes the built-in hours profile. If you omit it, the default profile applies: 15 minutes server-side revalidation and no expiry by time. It also warns about hosting: on serverless platforms the default in-memory entries typically do not persist across requests, while self-hosted Node.js and Docker keep them. How well your cache absorbs the 600 request budget therefore depends on where the app runs. Measure the hit rate after deploy rather than assuming it.

An error thrown inside a cached function reaches the caller as a reconstructed error, and the page recommends returning a serializable value for expected failures. For a 404 that is the null above.

#Which Companies House endpoints do most apps need?

Two cover most lookups:

NeedEndpointNotes from the reference
Check one companyGET /company/{companyNumber}API key, returns the company profile with an ETag header
Find a company by nameGET /search/companiesParameters q (required), items_per_page, start_index, API key

The search reference does not state default or maximum values for items_per_page or start_index, so the first test run should check how many results come back and how paging behaves rather than assuming numbers.

#How should I handle changes to the API?

The developer guidelines say two things about response bodies: your application must tolerate changes in the order of JSON members, and it must expect members it has not seen before. In TypeScript this argues against a strict schema that rejects unknown keys. Parse the fields you use, ignore the rest.

The versioning policy is per resource. Versions are requested through the Accept header, and each resource is versioned independently, with no global version number. Removing or renaming a field, changing a data type or changing a nested structure increments the version, while adding a field does not. A request with no Accept header, or with application/json or */*, gets the latest version. An unrecognised version returns 406, a recently expired one returns 410, and a deprecated version carries a CH-Expiry-Date header, typically three months after deprecation. Logging that header in production turns a future breaking change into a warning you can read weeks ahead.

#What are the data terms?

Three sources answer this, and they stop short of a full contract.

  • The gov.uk guidance on searching the register says the public data Companies House holds on companies is available free of charge, also through the API, and that all content is available under the Open Government Licence v3.0 except where otherwise stated.
  • The same page says the search databases are not intended as a source for bulk downloads, and that users generating unusually high volumes may be cut off without notice. A crawler that walks the register belongs elsewhere, and the free bulk data products are described on a separate Companies House page that I did not read.
  • The developer guides I read contain no separate terms of use and no attribution rules. The footer links to Crown copyright and to the policies page above.

Officer data is personal data. Companies House’s personal information charter says commercial organisations that build products from register data become controllers of the individuals’ personal data and must work out their own UK GDPR compliance, and that Companies House cannot advise on this. I am not a lawyer. If your product shows director names or dates of birth, take that question to your adviser before launch. In the build I can keep the personal fields out of cached and logged data.

#Checklist for a Companies House integration

  • Register the application and create an API Key application.
  • Restrict the key to your server addresses or domains.
  • Keep the key in a server-only variable and import server-only in the data module.
  • Call the API from Server Components or Route Handlers, never from the browser.
  • Wrap lookups in use cache with an explicit cacheLife.
  • Debounce search input, and log HTTP 429 and CH-Expiry-Date.
  • Parse only the fields you use.
  • Regenerate the key with each release.

#How does a project run?

  1. You send the use case, the endpoints you expect to call, the expected daily volume and your hosting. Expect an email answer within 24 hours on a working day.
  2. I write down the scope and my assumptions, with questions on caching, personal data fields and error states.
  3. I build on a staging copy, and you test with real company numbers.
  4. Production gets the change only once you approve the staging version in writing.

I work remotely, and decisions stay in email and shared documents. Everything else I build in Next.js is listed on the Next.js developer page.

Need this service: Next.js developer in Nottingham?

Describe your project by e-mail. I reply within 24 hours.

Describe your project

Explore other WordPress services and knowledge base