Skip to Content
dk-address

Quickstart

Install the package and render a working address field.

This page gets an unstyled address field working in a React app. You need React 19 or newer. You don't need an API key: KDS's shared token is the default.

Install the package

npm i @dk-address/react

Render a field

import { AddressInput } from "@dk-address/react";

export function AddressField() {
  return (
    <AddressInput onSelect={(selection) => console.log(selection.details)}>
      <AddressInput.Label>Address</AddressInput.Label>
      <AddressInput.Input />
      <AddressInput.Popup>
        <AddressInput.List />
      </AddressInput.Popup>
    </AddressInput>
  );
}

AddressInput searches KDS as people type, and onSelect runs once they pick a full address.

In the Next.js App Router, start this file with "use client": onSelect is a function, and a Server Component can't pass one. Server Components shows what renders without it.

Try it

Type Vesterbrog, pick the first street, type 28, pick the house number, then type st and pick a unit. onSelect then receives the full address: its id, floor, door, municipality, postal code and position. How it works explains each step.

The field has no styles yet. Give each part a className (plain CSS, CSS modules and Tailwind all work), or try the styled field on the AddressInput page first.

Next steps