Next.js developer in Copenhagen

Next.js for Danish businesses: the cookie order and Erhvervsstyrelsen guidance, MitID through a broker, and Danish and English routing. Remote, in writing.

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.
  • Local WordPress meetup: WordPress Copenhagen

My WordPress.org profile

A Next.js site for a Danish business meets two kinds of rules before the first release: what Danish law says about storing information on a visitor's device, and, if customers log in, how MitID reaches your site. This page covers both, as far as the official Danish documents go, and then the routing that serves a Danish and English version of every page. I am Mariusz Szatkowski, a solo developer based in Gdynia, Poland, working remotely and in writing.

#What the documentation says about locales

The Next.js guide on internationalization separates two jobs. Routing decides which URL serves which language. Localisation decides which strings appear on it. A locale is an identifier for language and formatting preferences, such as da for Danish without a region or en-GB for English as written in Britain.

Routing can use a sub-path (/fr/products) or a domain (my-site.fr/products). The guide recommends reading the browser’s language preference, which arrives as the Accept-Language header, to pick the locale. Everything else on this page follows from those two sentences.

For a Copenhagen business, my default is one domain with /da and /en. Whether you add a second domain depends on your marketing plans; Next.js handles either setup.

#Proxy replaces middleware

If you have read older Next.js articles on this topic, they put the redirect logic in middleware.ts. The proxy file convention says that middleware was deprecated and renamed to proxy in version 16.0.0, and that proxy defaults to the Node.js runtime. The npm registry shows 16.0.0 published on 22 October 2025, and 16.5.0, published on 2 December 2026, as the latest release on 3 December 2026.

The documentation explains the rename: the word middleware was too easily confused with Express middleware, and it recommends proxy only as a last resort. A codemod, npx @next/codemod@canary middleware-to-proxy ., renames the file and the function. When I take over a project that still has a middleware file, this is the first thing I check.

A minimal proxy for da and en, adapted from the documentation example:

// proxy.ts
import { match } from '@formatjs/intl-localematcher'
import Negotiator from 'negotiator'
import { NextRequest, NextResponse } from 'next/server'

const locales = ['da', 'en']
const defaultLocale = 'da'

function getLocale(request: NextRequest) {
  const header = request.headers.get('accept-language') ?? defaultLocale
  const languages = new Negotiator({ headers: { 'accept-language': header } })
    .languages()
    .filter((l) => l !== '*')
  return match(languages, locales, defaultLocale)
}

export function proxy(request: NextRequest) {
  const { pathname } = request.nextUrl
  const hasLocale = locales.some(
    (l) => pathname === `/${l}` || pathname.startsWith(`/${l}/`)
  )
  if (hasLocale) return

  request.nextUrl.pathname = `/${getLocale(request)}${pathname}`
  return NextResponse.redirect(request.nextUrl)
}

export const config = {
  matcher: ['/((?!_next|api|.*\\..*).*)'],
}

The matcher is my variant: the documentation example skips only _next, and I also skip API routes and anything with a file extension, so images and fonts are never redirected. The guide also shows a version of the matcher that runs the proxy on the root URL only. That is the one I choose when old deep links must keep working without a redirect hop.

#The [lang] segment and the dictionaries

The guide asks you to nest every special file under app/[lang]. The page then receives the language as a parameter:

// app/[lang]/page.tsx
import { notFound } from 'next/navigation'
import { getDictionary, hasLocale } from './dictionaries'

export default async function Page({ params }: PageProps<'/[lang]'>) {
  const { lang } = await params
  if (!hasLocale(lang)) notFound()
  const dict = await getDictionary(lang)
  return <h1>{dict.home.title}</h1>
}

hasLocale narrows the string to the supported locales, and notFound() renders the not-found UI for anything else, so /fr does not quietly serve Danish. The dictionaries are plain JSON files loaded with a dynamic import in a file marked server-only. The documentation states the consequence: layouts and pages in app/ are Server Components by default, so the size of the translation files does not affect the client-side JavaScript bundle. Only the resulting HTML reaches the browser.

The same guide shows next/root-params, which exports a getter for each dynamic segment above the root layout. With it, getDictionary() reads the locale itself and no component needs lang passed down. The limit is stated too: root parameter getters work in Server Components and server-side utilities, not in Client Components, Server Actions or Route Handlers. On a Danish site that has a Server Action for a contact form, that means the language travels in a hidden field or the action reads it from the request, and I note this in the written scope.

#Static pages per language

For a marketing site, I want both languages built at deploy time. The guide’s static rendering example puts generateStaticParams in the root layout and sets the lang attribute on the html element:

// app/[lang]/layout.tsx
export async function generateStaticParams() {
  return [{ lang: 'da' }, { lang: 'en' }]
}

export default async function RootLayout({ children, params }: LayoutProps<'/[lang]'>) {
  return (
    <html lang={(await params).lang}>
      <body>{children}</body>
    </html>
  )
}

Two details from the generateStaticParams reference matter here. First, dynamicParams = false makes every path you did not list return a 404 instead of being rendered on demand. Second, that option is only available without Cache Components, and with Cache Components a dynamic route must return at least one param, because an empty array is a build error. If the project uses Cache Components, I check that rule before the first deployment, not after the first red build.

#Language alternates in metadata

Each page should name its other-language twin. The generateMetadata reference shows an alternates field with a languages map, and it renders the canonical link and one hreflang link per entry:

export async function generateMetadata({ params }: PageProps<'/[lang]'>) {
  const { lang } = await params
  return {
    alternates: {
      canonical: `/${lang}`,
      languages: { da: '/da', en: '/en' },
    },
  }
}

For pages that exist in only one language, the map lists only that language. Google’s rules for the tags, including the return links, are on the localized versions page, and I cover the Brussels version of that problem on the Next.js page for Brussels.

#What I check before a Danish and English build goes live

CheckWhat I look at
Language on every URL/da/... and /en/... both return 200, an unknown prefix returns 404
The html elementlang matches the path on every page
Redirect scopeOnly URLs without a prefix are redirected, never assets or API routes
DictionariesNo key exists in one language only
AlternatesEach page lists itself and its twin
Consent bannerSame language as the page, tested on a clean profile
Static outputBoth languages appear in the build output

The rule sits in the cookie order (BEK 1148 of 9 December 2011). Section 3 bars storing information on, or reading it from, a visitor’s device unless the visitor has consented after receiving full information. Section 3(2) lists what that information must contain: clear and easily understood language, the purposes, who is behind the storage, an immediately available way to refuse or withdraw consent, and a permanently reachable place to read it. Section 4 exempts storage that only carries a communication, or that is required to deliver a service the visitor expressly asked for. Under section 5 a breach is punishable by fine.

Erhvervsstyrelsen’s guidance (VEJ 10189 of 10 December 2019, marked as in force in the retsinformation print of 3 December 2026) turns this into cases. A login function or a shopping basket needs no consent. Statistics, personalised and marketing cookies do, including tools such as Google Analytics. Following the EU Court of Justice judgment of 1 October 2019 (case C-673/17), a pre-ticked box is not consent, and Erhvervsstyrelsen concluded that “carry on browsing” cannot count as consent either. The banner must also state how long each cookie lasts, and the same guidance says GDPR applies to whatever you do with the data afterwards.

Statistics have a footnote. In October 2021 Erhvervsstyrelsen announced that it would no longer prioritise supervision of simple statistics. Datatilsynet’s note of 26 October 2021 records that and adds that GDPR and the Danish Data Protection Act still apply wherever personal data about visitors is processed. The trade body Dansk Erhverv reported the conditions as own use only, no visitor profiles and no passing on to third parties, and that the order itself had not changed. A choice not to prioritise is not an exemption, so I treat consent as the default and leave the decision on statistics to you and your adviser.

What that means in the build, as my method rather than a legal opinion:

StepWhat I do
InventoryList every cookie, localStorage key and third-party request the finished build produces: purpose, who sets it, lifetime
LanguageThe proxy above reads Accept-Language and the URL carries the language, so no language cookie is needed to make routing work
Loading orderAnalytics, maps and video load only after a recorded choice, never before
RefusalReject sits on the first layer of the banner, as section 3(2) point 4 asks for an immediately available way to refuse
WithdrawalA footer link reopens the choice on both /da and /en
DurationThe cookie list shows each lifetime, as the guidance requires

The authority that supervises the cookie order is Erhvervsstyrelsen, and for personal data it is Datatilsynet. I give you the finished inventory in writing and you decide, with your adviser, which entries need consent.

#MitID login for a Next.js site

MitID is not a library you install. The MitID site explains the broker model: a broker relays the end-user authentication and sits between MitID and the service provider, and both public and private service providers must connect through one before they can offer MitID login. NemLog-in acts as the broker for public service providers.

The NemLog-in login page states the terms. A system that performs a public-authority task must use NemLog-in, with free login and single sign-on. If it performs no such task, login is still possible but against payment and without single sign-on. Each organisation judges for itself whether it performs a public-authority task. The integration steps are to create the system in NemLog-in Administration, pass an integration test and then go to production. The test page lists metadata examples for OIOSAML 3 and OIOSAML 4 and test report templates for private systems.

The reference implementations on the same site are in Java and .NET, and they cover OIOSAML 3, not yet OIOSAML 4. Node.js is not named. So I do not promise a login inside the Next.js process before the broker’s own documentation has been read against your setup. In the written scope I split the work in two: the broker agreement and the identity integration, which the broker or your IT supplier carries, and the Next.js side, meaning protected routes, session handling and the Danish and English screens around the login. Commercial brokers and what they offer are your choice to make; I read their documentation with you, in writing.

#How a Danish and English project runs

  1. You send a short written brief: the current site URL or the idea, the two languages, the content source (Markdown, a headless CMS, or headless WordPress) and the deadline.
  2. I reply with written questions, then a written scope with assumptions and exclusions.
  3. I build on a staging URL and send each milestone with a note on what changed.
  4. You accept in writing, and I hand over the repository with a README for the next developer.

I design the layout (wireframes and visual design) or build from yours, and I do not offer calls or meetings. Everything is in writing, from Gdynia, in the same time zone as Denmark.

#Send me the brief

Write through the contact page with the site URL, the goal, the stack today and your deadline. The first written estimate costs nothing, and I answer by email within 24 hours on working days. Denmark and Poland share the same clock.

Rundetaarn, Copenhagen

Photo: Dietmar Rabich, CC BY-SA 4.0, Wikimedia Commons.

See also in Denmark

Need this service: Next.js developer in Copenhagen?

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

Describe your project

Explore other WordPress services and knowledge base