This is a React + TypeScript + Vite project powered by Tailwind CSS, and the UNDP Design System, bootstrapped with @undp/create-app.
It includes:
- React 19.x with React compiler
- UNDP Design System
- Routing with TanStack Router
- Data fetching with TanStack Query
- TailwindCSS
- Code linting and formatting via Biome
This project uses npm.
For installation you will need to install node and npm, if you don't already have it. node and npm can be installed from here.
To install the project, simply run npm install in the project folder in the terminal on Mac or Command Prompt on Windows.
To start the project locally:
npm run devThis is run the app in development mode. Open http://localhost:5173/ to view it in the browser.
The page will reload if you make edits. You will also see any lint errors in the console.
npm run dev: Executesviteand start the local server for local deployment.npm run build: Executestsc && vite buildand builds the app for production and deployment.npm run preview: Executesvite previewand serves the static build output (from vite build) locally.npm run clean: Executesrimraf node_modules && rimraf dist && rimraf package-lock.jsonand remove node_modules folder, dist folder and package-lock.json.npm run check: Executesbiome check .and lists all the linting and prettier errors.npm run check:fix: Executesbiome check --write .and resolve all the linting and prettier errors.
This project uses Biome integrated to automatically format and lint your code.
If you’re using Visual Studio Code, install:
Your editor should now show linting errors and automatically fix issues where possible.
More info: Biome Docs
Recommendation
On Visual Studio Code, you can also use the i18n Ally extension for a better translation workflow. It provides features such as translation key autocomplete, inline translation previews, missing key detection, and quick navigation between translation files.
This project uses Tailwind CSS for styling and and includes pre-configured design tokens from the UNDP Design System.
- Create a new translation file (e.g.
src/locales/<language code>/common.json) containing all translated keys. - Import and register the language in your i18next
src/i18n.ts. - Add the new language in
LANGUAGEvariable insrc/constants.ts. - Add the language code to your language selector or supported languages list.
- Switch languages using
i18n.changeLanguage('fr')and i18next will load the corresponding translations.
Routing is powered by TanStack Router and uses a code-based configuration (in the ./src/main.tsx).
Example: add an /about route:
const aboutRoute = createRoute({
getParentRoute: () => rootRoute,
path: "/about",
component: () => <h1>About</h1>,
});Then, register it in your routeTree:
const routeTree = rootRoute.addChildren([indexRoute, aboutRoute]);You can define your component in another file:
import About from "./components/About.tsx";
const aboutRoute = createRoute({
getParentRoute: () => rootRoute,
path: "/about",
component: About,
});More info: Code Based Routing.
Now that you have two routes you can use a Link component to navigate between them.
Use the Link component for client-side navigation:
import { Link } from "@tanstack/react-router";
<Link to="/about">About</Link>More info: Link documentation.
Please note: Language routing is done at in src/main.tsx
Data fetching is powered by TanStack Query for efficient, declarative data fetching and caching.
For questions or feedback, contact us at data@undp.org.