Countries Explorer
A country explorer with search, region filtering, detail pages, and bordering countries over a validated local dataset.
- Next.js
- React
- TypeScript
- Tailwind CSS
- Zod
Problem
The Frontend Mentor challenge asked for a country listing with name search, region filtering, a detail page with information and borders, and a light/dark theme switch.
The project shipped a data.json in the legacy REST Countries v2 shape, so the application also had to normalize and validate that data before rendering it.
Role
I implemented the complete solution: the listing and detail routes, dataset normalization, Zod validation, and theme switching.
Decisions
- Validate data at the boundary.
The dataset is treated as untrusted input. A Zod schema describes only the fields the interface uses, and if validation fails the route responds with notFound instead of rendering a broken view.
- Resolve borders in memory.
The detail route indexes the dataset by alpha3Code once and resolves both the country and its neighbors from that map, without requesting each border from an API.
- Filter in a single useMemo.
Search and region filtering are combined over the already validated array. Typing or changing the region does not trigger additional requests, and the search mirrors the prefix behavior shown in the design.
- Theme with CSS variables.
The palette lives in variables for :root and .dark, and Tailwind maps it with @theme inline. next-themes toggles the document class without duplicating styles per component.
Result
The listing and detail views work over the local dataset, with loading and not-found states, and the light or dark theme persists across navigation.