Introduction
Danish address autocomplete for React, built on KDS Adressevælger, the replacement for DAWA's autocomplete.
dk-address is an address field for Danish addresses. People type a street name, pick a house number and a unit, and your app gets the full address with its id, postal code, municipality and position.
shadcn/ui
A styled field you copy into components/ui and own.
Ant Design
An AutoComplete that works as a Form.Item control, with the address id as its value.
Tailwind or your own CSS
Style the unstyled parts and wrap them in your own field component.
MUI, Mantine and others
Drive your component library's own autocomplete with a hook.
Get started
Install the package and render a field in two steps, then see what happens when someone picks a suggestion:
Quickstart
Install @dk-address/react and render a working address field.
How it works
How the field takes people from a street name to a full address.
What is KDS Adressevælger?
KDS Adressevælger is the address search API from Klimadatastyrelsen (KDS), the Danish Agency for Climate Data. It searches Danmarks Adresseregister (DAR), the national address register, and replaces DAWA's autocomplete. New and changed addresses are searchable the day after they're registered.
You don't need to sign up. Until KDS introduces user management, everyone uses the same shared token, and dk-address sends it for you.
What dk-address adds
KDS returns suggestions, but turning them into a field people can fill in takes more than a list. dk-address handles:
- Caret placement: picking a street leaves the caret where the house number goes (
Vesterbrogade |, 1620 København V), and picking a building leaves it where floor and door go. KDS's own component does neither. - House numbers by prefix: KDS only matches whole house numbers, so
2finds nothing on the way to28. Once a street is picked, dk-address matches its house numbers as you type. - English, typed results: one
Suggestiontype with English field names instead of KDS's five Danish result shapes, and errors you can catch instead of Danish text. - Your UI: unstyled parts that take your
className, ready blocks for shadcn/ui and Ant Design, or a hook for any other autocomplete.
KDS also publishes its own JavaScript component. Compared with KDS's component puts the two side by side, from installing to what your code depends on.
Packages
Most apps only install @dk-address/react. It brings the other two along:
| Package | Use it to |
|---|---|
@dk-address/react | Render the address field in React |
@dk-address/core | Get the same behaviour without React |
@dk-address/client | Call KDS yourself, with English types and errors |
To import from core or client in a React app, for example createClient() in your tests, add that package to your dependencies too.