All Moroccan cities and their regions are contained in this package, which was created by a Moroccan JavaScript student.
you can use this package with react select library and create a custom select with search button.
npm install list-of-moroccan-cities
yarn add list-of-moroccan-cities
const { cities } = require("list-of-moroccan-cities");
it's will return an array of objects like this
[
{
"id": "0",
"name": "Afourar",
"label": "Afourar"
},
{
"id": "1",
"name": "Agadir",
"label": "Agadir"
}
]
const { regions } = require("list-of-moroccan-cities");
it's will return an array of objects like this
[
{
"id": "1",
"name": "Tanger-Tétouan-Al Hoceïma",
"region": "Tanger-Tétouan-Al Hoceïma"
},
{
"id": "2",
"name": "l'Oriental",
"region": "l'Oriental"
}
]
const { citiesWithRegion } = require("list-of-moroccan-cities");
it's will return an array of objects like this
[
{
"id": "0",
"name": "Afourar",
"label": "Afourar",
"region": "Béni Mellal-Khénifra"
},
{
"id": "1",
"name": "Agadir",
"label": "Agadir",
"region": "Souss-Massa"
}
]
I'm using this person's Alaouy repository to build this package, so I want to give him a big thank thanks. his repository data