Entylink
Tutorial

Build a UK company autocomplete for signup forms in Next.js

Use Entylink search results to build a company autocomplete in Next.js, then capture the selected company number for downstream onboarding, verification, and monitoring workflows.

uk company autocomplete api tutorialnext js company search autocompletebusiness signup company lookupuk company search ui tutorial
Guide details
Read time
9 min
Estimated for an engineer implementing the flow
Level
Intermediate
Assumes comfort with APIs and backend basics
Intent
Implementation
Real product or compliance workflows
Who this is for

Start from the real implementation problem

Target readers
Frontend engineers building business signup formsProduct engineers improving onboarding conversionDevelopers replacing manual company number entry
01Show matching UK companies as the user types
02Store the selected company number, not just the label
03Set up the flow so the chosen entity can be verified later
Prerequisites

Keep the setup explicit

01

A Next.js app

02

An internal API route or server action that can call Entylink

03

An Entylink API key stored server-side

Step by step
Step 01

Create a server-side search route

Keep the Entylink key on the server. The browser should call your own route, which forwards validated search terms to Entylink.

Next.js route handlerExample
import { NextResponse } from "next/server";

export async function GET(request: Request) {
  const { searchParams } = new URL(request.url);
  const q = (searchParams.get("q") || "").trim();

  if (!q) return NextResponse.json({ items: [] });

  const response = await fetch(
    `https://api.entylink.com/v1/search?q=${encodeURIComponent(q)}&items_per_page=8`,
    {
      headers: {
        Authorization: `Bearer ${process.env.ENTYLINK_KEY}`,
      },
    },
  );

  const payload = await response.json();
  return NextResponse.json({ items: payload.data.items });
}
Step 02

Debounce input on the client

Do not call the API on every keystroke with no guardrails. Debouncing keeps the UX responsive and the request pattern sane.

Client componentExample
const [query, setQuery] = useState("");
const [items, setItems] = useState([]);

useEffect(() => {
  if (query.trim().length < 2) {
    setItems([]);
    return;
  }

  const timeout = setTimeout(async () => {
    const response = await fetch(`/api/company-search?q=${encodeURIComponent(query)}`);
    const payload = await response.json();
    setItems(payload.items);
  }, 250);

  return () => clearTimeout(timeout);
}, [query]);
Step 03

Persist the company number after selection

The visible label is not enough. Store the chosen company number in form state so later steps can call `/v1/company/:number` and related endpoints reliably.

Selection modelExample
function selectCompany(item: {
  company_number: string;
  company_name: string;
}) {
  setValue("companyNumber", item.company_number);
  setValue("companyName", item.company_name);
  setItems([]);
}
Step 04

Treat autocomplete as onboarding infrastructure

The commercial value of autocomplete is not just a nicer field. It reduces resolution errors and creates a clean handoff into verification and monitoring workflows.