This example shows how to integrate react-azure-maps into your Next.js application.
- Install react-azure-maps to your
dependencies
.
yarn add react-azure-maps
- Import the following style sheet to your component or page
import 'azure-maps-control/dist/atlas.min.css'
- Since azure-maps-control is a client side library and it cannot be imported in your server side code. Therefore, you will need to use next/dynamic to load your Map component at client side.
// pages/index.tsx
import type { NextPage } from "next";
import dynamic from "next/dynamic";
const DynamicMap = dynamic(() => import("../components/Map"), {
ssr: false,
});
const Home: NextPage = () => <DynamicMap />;
export default Home;
-
Update your AzureMaps subscriptionKey in `/components/Map.tsx``
-
Run the development server
yarn dev
- Open http://localhost:3000 with your browser to see the result.