Live demo
interactive
Selected location
BjLocationData is an open JavaScript library providing departments, towns, districts, and neighborhoods for Benin Republic. Drop a ready-made hierarchical selector into any web page — no backend, no API keys, no dependencies.
Quick start
Use the CDN bundle directly, install via npm, or import the ES module. All three expose the same BjLocationData API.
<script src="https://unpkg.com/location_data_bj/…/bundle.js"></script> <div id="holder"></div> <script> BjLocationData.init({ holderQuerySelector: "#holder" }); </script>
npm install location_data_bj import { departmentList, townsList } from 'location_data_bj' const departments = departmentList() // → IDepartment[] const towns = townsList() // → ITown[]
BjLocationData.init({
holderQuerySelector: '#holder',
useHierarchy: true, // filter child lists when parent changes
useDefaultSelect: true, // include a blank "– select –" option
level: ['department', 'town', 'district', 'neighborhood'],
onDepartmentChange: (v) => console.log('department', v),
onTownChange: (v) => console.log('town', v),
onDistrictChange: (v) => console.log('district', v),
onNeighborhoodChange: (v) => console.log('neighborhood', v),
onChanges: (v) => console.log('any change', v),
});
Data
All administrative divisions of Benin Republic — from the 12 departments down to individual neighborhoods — shipped as static data in the bundle.
IDepartment, ITown, IDistrict, INeighborhood) exported for type-safe usage.
departmentList, townsList, etc.) independently to build your own UI.