When building applications with the ArcGIS Maps SDK for JavaScript, there are multiple options, each with their own advantages depending on your specific goals and requirements. For a small project, the ArcGIS Content Delivery Network (CDN) might be the best approach to get started. For larger or complex applications built with a modern JavaScript framework or build tool, installing component packages from npm is best practice.
CDN
Using the ArcGIS CDN is a straightforward way to include the SDK's capabilities in your application without needing to install any packages locally. This is ideal for simple applications, quick prototyping, or when you want to leverage optimized cloud caching for faster module downloads.
npm
If you're building a more complex application, especially within modern build tools or JavaScript frameworks like React, Vue, or Angular, then it is recommended to install the JavaScript Maps SDK via npm. This allows you to manage any packages as a dependency in your project, take advantage of npm's package management capabilities, and integrate more seamlessly with modern build tools like Webpack and Vite.
Each component package from the JavaScript Maps SDK is designed to be framework-agnostic, meaning they are compatible with most JavaScript frameworks or no framework at all. However, to make components feel familiar to use within specific frameworks, additional packages are available that provide a more tailored experience. In the case of @arcgis/map-components, @arcgis/map-components-react is available as an additional npm package.
Access tokens
Access tokens are required to access ArcGIS services, such as basemaps, geocoding, and routing. Visit your portal and create an access token with custom privileges and referrers for your specific needs. Include your access token in the tutorials and samples when required in the instructions. You can use a global API key, as well as more fine-grained API keys on specific classes.