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:^2.0
php -d memory_limit=1G artisan world:install

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

For the default database cache, run application migrations first. Existing 1.x users should review the 2.0 upgrade guide or stay with the 1.x documentation.

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.