
Mapbox Search Integration
Add Mapbox Search Box autocomplete (addresses and POIs) to a React map and fly the camera on result selection without hand-rolling debouncing and session tokens.
Overview
mapbox-search-integration is an agent skill for the Build phase that guides Mapbox Search Box and Search JS setup for autocomplete search that moves the map to a chosen place.
Install
npx skills add https://github.com/mapbox/mapbox-agent-skills --skill mapbox-search-integrationWhat is this skill?
- Recommends Search Box API over Geocoding when users need both addresses and businesses/POIs
- Primary path: @mapbox/search-js-react SearchBox with onRetrieve and map.flyTo()
- Custom UI path: @mapbox/search-js-core instead of raw fetch() for debouncing and session tokens
- Eval-backed guidance for React autocomplete plus keyboard-friendly custom result rendering
Adoption & trust: 895 installs on skills.sh; 64 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You have a Mapbox map in React but no reliable pattern for autocomplete that covers businesses and addresses without brittle fetch() and missing session-token discipline.
Who is it for?
Solo builders adding search-as-you-type location pickers to Mapbox GL or React map products.
Skip if: Teams that only need one-off geocoding on the server with no interactive search UI, or apps not using Mapbox at all.
When should I use this skill?
Building a Mapbox map with user-driven place search, autocomplete, or custom search UI in React or vanilla web.
What do I get? / Deliverables
You implement Search Box via Search JS React or Core with correct API choice, onRetrieve handling, and flyTo behavior ready to harden with mapbox-token-security next.
- Search Box integration pattern (React or Core)
- onRetrieve handler that updates map camera
- Decision notes: Search Box vs Geocoding and SDK vs raw API
Recommended Skills
Journey fit
Canonical shelf is Build because the skill wires Mapbox Search JS into product UI during implementation, not during launch SEO or ops monitoring. integrations fits third-party map/search SDK wiring—Search Box API, @mapbox/search-js-react, and Core for custom dropdowns.
How it compares
Opinionated Mapbox Search JS integration guide—not a generic geocoding cheat sheet or an MCP map server.
Common Questions / FAQ
Who is mapbox-search-integration for?
Indie and solo developers building web or hybrid apps with Mapbox who need autocomplete for addresses and POIs in the map UI.
When should I use mapbox-search-integration?
During Build integrations when you wire SearchBox or a custom dropdown to Mapbox; after validating the product needs map search, before ship-time token URL restrictions.
Is mapbox-search-integration safe to install?
Review the Security Audits panel on this Prism page and inspect the skill source; pairing with mapbox-token-security is recommended before exposing any pk.* token in the client.
Workflow Chain
Requires first: mapbox token security
Then invoke: mapbox token security
SKILL.md
READMESKILL.md - Mapbox Search Integration
{ "skill_name": "mapbox-search-integration", "evals": [ { "id": 1, "prompt": "I'm building a React app with a Mapbox map. I want users to type in a search box, see autocomplete suggestions for both addresses and businesses, and click a result to fly the map to that location. What's the recommended implementation?", "expectations": [ "Recommends Search Box API (not Geocoding API) — users need both addresses and businesses/POIs", "Recommends Search JS React (`@mapbox/search-js-react`) as the easiest option for React apps with a built-in UI", "Shows the SearchBox component with an onRetrieve callback to get coordinates and call map.flyTo()", "Does NOT recommend direct API calls with fetch() as the primary approach — SDK handles debouncing, session tokens, and UI" ] }, { "id": 2, "prompt": "I want to add an autocomplete search box to my web app but I need a completely custom dropdown UI — my own styling, keyboard navigation, and result rendering. Should I call the Mapbox Search Box API directly with fetch() requests, or is there a better approach?", "expectations": [ "Recommends Search JS Core (`@mapbox/search-js-core`) over direct API calls for custom UI — it provides the API wrapper without imposing UI", "Explains that calling the API directly means manually implementing debouncing and session token management", "Notes that Search JS Core handles debouncing and session tokens automatically", "If direct API is used anyway, explains that session tokens are required for proper billing and must be generated per search session" ] }, { "id": 3, "prompt": "My app needs to geocode addresses — users type a US address and I get back coordinates. I'm looking at the Mapbox Geocoding API. Should I use that or the Search Box API?", "expectations": [ "Recommends Search Box API as the default choice for interactive address search", "Explains Search Box API has session-based pricing which is more cost-efficient for autocomplete/interactive use", "Notes Geocoding API is appropriate for batch geocoding, maintaining an existing integration, or permanent geocoding (not search)", "Notes SDKs (Search JS) are preferred over direct API calls for web integration" ] } ] } # Android: Search SDK for Android ## Option 1: Search SDK with UI (Easiest) **When to use:** Android app, want pre-built search UI, fastest implementation **Installation:** ```gradle // Add to build.gradle dependencies { implementation 'com.mapbox.search:mapbox-search-android-ui:2.0.0' implementation 'com.mapbox.maps:android:11.0.0' } ``` **Complete implementation with built-in UI:** ```kotlin import com.mapbox.search.ui.view.SearchBottomSheetView import com.mapbox.maps.MapView class SearchActivity : AppCompatActivity() { private lateinit var searchView: SearchBottomSheetView private lateinit var mapView: MapView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_search) mapView = findViewById(R.id.map_view) // SearchBottomSheetView provides complete UI automatically searchView = findViewById(R.id.search_view) searchView.initializeSearch( savedInstanceState, SearchBottomSheetView.Configuration() ) // Handle result selection searchView.addOnSearchResultClickListener { searchResult -> // SDK handled all the search interaction val coordinate = searchResult.coordinate mapView.getMapboxMap().flyTo( CameraOptions.Builder() .center(Point.fromLngLat(coordinate.longitude, coordinate.latitude)) .zoom(15.0) .build() ) searchView.hide() } } } ``` ## Option 2: Se