Stable /api/countries

Country selector

A searchable, keyboard-friendly selector backed by the complete World country dataset.

Client-side search ISO code and flag Keyboard navigation Single API request

Installation

Install once, use everywhere.

composer require nnjeim/world
php artisan world:install

React, Angular, and Vue consume the same Laravel API; no frontend package is required.

Playground

Live behavior and copy-ready code.

Country selector

Connecting to the World API…

Live preview

Selected value

Loading…

component.blade.php
Loading example…

API reference

Request only the fields you need.

GET /api/countries?fields=iso2&search=rom
Endpoint
/api/countries
Fields used
id, name, iso2

Component contract

Props

NameTypeDefaultDescription
name string country_id Submitted form-field name.
value number|null null Initially selected country ID.
required boolean false Marks the control as required.
disabled boolean false Prevents selection changes.

Events

change Country

Emitted after a country is selected.

loading boolean

Reports API loading state.

error Error

Reports an unavailable or invalid response.

Validation guidance

  • Submit the numeric country ID.
  • Resolve the ID against your local countries table.
  • Use `required` only when the product flow requires a country.

Accessibility checklist

  • ✓Associate a visible label with the control.
  • ✓Expose expanded state and the active option on custom comboboxes.
  • ✓Support Arrow keys, Enter, and Escape.
  • ✓Announce loading, empty, and selected states.