# mapkit-react
Use Apple Maps in your React apps!
This library wraps [MapKit JS](https://developer.apple.com/documentation/mapkitjs) in React components. Its declarative, straightforward, and React-idiomatic API allows you to quickly add maps to your project, from prototype to production.
## Demo
Check out [**the Storybook examples**](https://nicolapps.github.io/mapkit-react/) to see the available components, experiment with their parameters, and read some code samples.
You can run the examples locally by cloning the project and running the following command:
```sh
STORYBOOK_MAPKIT_JS_TOKEN="…" npm run storybook
```
Replace `…` by your MapKit JS token (you can learn how to generate one on the [MapKit JS documentation](https://developer.apple.com/documentation/mapkitjs/creating_and_using_tokens_with_mapkit_js)).
You can also see the library used in production on [CMUEats](https://cmueats.com/map) and [CMU Map](https://cmumap.com).
## Usage
First, add the library to your project like this:
```sh
npm install mapkit-react
```
You can then use the library in your project like this:
```tsx
import React from 'react';
import { Map, Marker } from 'mapkit-react';
function MyComponent() {
return (
);
}
```
You can also pass a function that returns a token (sync or async). MapKit JS may call this throughout a session when it needs a new token — for example when a short-lived JWT expires. Prefer minting tokens on your server; never put your MapKit private key in client-side code.
```tsx
function MyComponent() {
return (
);
}
```
MapKit JS is initialized once per page, so all `