Skip to content

rironib/next-countries

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Next Countries

A performance-first library providing data for 248 countries, optimized for Next.js App Router and React Server Components. Zero dependencies, built-in TypeScript support, and extremely lightweight.

Install

Choose your package manager:

# npm
npm install next-countries

# pnpm
pnpm add next-countries

# yarn
yarn add next-countries

# bun
bun add next-countries

Quick Start

It's as easy as this:

import { countries, getCountryByCode } from "next-countries";

// 1. Get all countries
const list = countries;
console.log(list[0]); // { name: 'Afghanistan', code: 'AF', ... }

// 2. Lookup by ISO Alpha-2 code
const us = getCountryByCode("US");

// 3. Simple Select example in Next.js
export default function CountrySelector() {
  return (
    <select>
      {countries.map((c) => (
        <option key={c.code} value={c.code}>{c.name}</option>
      ))}
    </select>
  );
}

Features

  • Zero Dependencies: Keeps your bundle size minimal.
  • Next.js Optimized: Works seamlessly with React Server Components.
  • Standard Compliant: Includes ISO-3166-1 (Alpha-2, Alpha-3) and numeric codes.
  • TypeScript: High-quality code suggestions and full type safety built-in.
  • Fast Lookup: Includes helper functions to find countries by name or codes.

License

MIT

About

Simple country list optimized for Next.js App Router and React Server Components.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors