Before installing ArcGIS REST JS, make sure your system meets the System requirements.
ArcGIS REST JS is compatible with a wide array of use cases and is distributed as native ES modules, CommonJS modules, and UMD modules. You can install and use ArcGIS REST JS in several ways:
- Node.js: for server-side or command-line applications
- Bundlers: for apps built with bundlers (Vite, Webpack, etc.)
- Browsers: for demos or simple web pages (via CDN or import maps)
Node.js
To use ArcGIS REST JS in a backend or Node.js application, first install the packages you need using your preferred package manager, such as NPM or Yarn. For a description of each package, go to the Introduction to ArcGIS REST JS.
npm install @esri/arcgis-rest-request
npm install @esri/arcgis-rest-feature-service
npm install @esri/arcgis-rest-geocoding
npm install @esri/arcgis-rest-routing
npm install @esri/arcgis-rest-demographics
npm install @esri/arcgis-rest-elevation
npm install @esri/arcgis-rest-portal
npm install @esri/arcgis-rest-developer-credentials
npm install @esri/arcgis-rest-basemap-sessionsOnce installed, you can import or require modules depending on your Node setup.
ES modules
ESM is the modern JavaScript module system used by default in most new projects. To use it, set "type" in your package.json, or give your files a .mjs extension. This allows you to use the import syntax in your JavaScript code.
This example shows how to import a classes from the arcgis-rest-geocoding package.
import { geocode } from "@esri/arcgis-rest-geocoding";CommonJS
CommonJS is the older Node.js module format. Use this if your project hasn’t migrated to ESM yet.
const { geocode } = require("@esri/arcgis-rest-geocoding");Bundlers
If you are using a bundler like Vite, Webpack, or Parcel, ArcGIS REST JS works out-of-the-box because it ships ES modules.
import { geocode } from "@esri/arcgis-rest-geocoding";Browsers
You can load ArcGIS REST JS directly in the browser using CDN with a global object or with an import map.
CDN with a global object
CDN is a viable option for demos and smaller applications. The library is available on two CDNs: unpkg, which can be used with a simple <script tag, and esm.run, which is optimized for serving ES modules.
<script src="https://unpkg.com/@esri/arcgis-rest-geocoding@4/dist/bundled/geocoding.umd.min.js"></script>
<script>
// all packages are added to an `arcgisRest` property on the global object
const { geocode } = globalThis.arcgisRest;
</script>CDN with an import map
Import maps let you use import statements in browsers without a bundler. The import map specification is well supported by all major browsers.
<body>
<script type="importmap">
{
"imports": {
"@esri/arcgis-rest-geocoding": "https://esm.run/@esri/arcgis-rest-geocoding@4"
}
}
</script>
<script type="module">
import { geocode } from "@esri/arcgis-rest-geocoding";
</script>
</body>