Geocoder
A geocoder component that provides search and autocomplete functionality for location-based queries. It can be used to find addresses, places, or points of interest based on user input.
Installation
Run the following command to install the `geocoder` components:
npx shadcn-svelte@latest add https://more-shadcn.noair.fun/r/geocoder.json
Result labels
Nominatim's
display_name is the complete administrative hierarchy, which is rarely
what you want to show:By default the geocoder requests
addressdetails=1 and assembles a compact address
from the structured fields instead — street, settlement and country only. Set format="full" to go back to the raw string, or pass a function for anything else.format="full"
Ordering
Address layout differs by country along two axes: whether the house number comes before or
after the street, and whether the postcode comes before or after the city. Each result is
ordered using its own
country_code, so a mixed result list stays correct.continental Musterstraße 12, 12345 Musterstadt, Austria
french 12 Rue de l'Exemple, 75000 Exempleville, France
anglo 12 Example Street, Springfield 12345, United States
Countries that are not mapped fall back to
anglo. Pass convention to
force one layout everywhere regardless of the result's country.Custom rendering
Pass a
locationSnippet to take over the markup of each result. The formatAddress helper is exported, so you can still reuse the label logic — here it
builds a two line entry with the street on top and the country muted underneath.Usage policy
The default provider is the public Nominatim instance, whose usage policy asks for an
identifying
User-Agent or Referer, caps requests at one per second
and forbids heavy use. For anything beyond light traffic, proxy the request through your own
backend or run your own Nominatim instance.