npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rerdev/arcgis-proxy

v0.3.0

Published

A minimal read-only ArcGIS MapServer proxy for Next.js App Router.

Readme

ArcGIS Proxy

A minimal read-only ArcGIS MapServer proxy for Next.js App Router.

Installing

npm install @rerdev/arcgis-proxy

Usage

Browser code calls your same-origin API route. The MapServer URL and credentials stay on the server.

fetch("/api/arcgis/2?f=json");

fetch("/api/arcgis/2/query", {
  method: "POST",
  headers: { "content-type": "application/x-www-form-urlencoded" },
  body: new URLSearchParams({
    f: "json",
    where: "OBJECTID = 1",
    outFields: "OBJECTID",
    returnGeometry: "false",
  }),
});

With the ArcGIS Maps SDK for JavaScript, point the layer at the same route:

import Map from "@arcgis/core/Map.js";
import MapImageLayer from "@arcgis/core/layers/MapImageLayer.js";

const map = new Map({
  layers: [
    new MapImageLayer({
      url: "/api/arcgis",
    }),
  ],
});

The proxy supports GET and POST read operations. ArcGIS mutation operations are rejected.

Quick start

Create app/api/arcgis/[[...path]]/route.ts:

import {
  createArcGISProxy,
  toNextJsHandler,
} from "@rerdev/arcgis-proxy";

const proxy = createArcGISProxy({
  mapServerUrl: process.env.ARCGIS_MAP_SERVER_URL!,
  bearerToken: process.env.ARCGIS_BEARER_TOKEN!,
});

export const { POST, GET } = toNextJsHandler(proxy);

For static bearer authentication, set both values in .env.local:

ARCGIS_MAP_SERVER_URL=https://gis.example.com/rest/services/Cadastre/MapServer
ARCGIS_BEARER_TOKEN=replace-with-a-server-token

Or let the proxy acquire and reuse an ArcGIS OAuth2 token:

const proxy = createArcGISProxy({
  mapServerUrl: process.env.ARCGIS_MAP_SERVER_URL!,
  oauth2: {
    tokenUrl: process.env.ARCGIS_TOKEN_URL!,
    clientId: process.env.ARCGIS_CLIENT_ID!,
    clientSecret: process.env.ARCGIS_CLIENT_SECRET!,
  },
});

export const { POST, GET } = toNextJsHandler(proxy);
ARCGIS_MAP_SERVER_URL=https://gis.example.com/rest/services/Cadastre/MapServer
ARCGIS_TOKEN_URL=https://gis.example.com/oauth2/token
ARCGIS_CLIENT_ID=replace-with-client-id
ARCGIS_CLIENT_SECRET=replace-with-client-secret

For an ArcGIS Server generateToken endpoint, use username/password authentication:

const proxy = createArcGISProxy({
  mapServerUrl: process.env.ARCGIS_MAP_SERVER_URL!,
  arcgisToken: {
    tokenUrl: process.env.ARCGIS_TOKEN_URL!,
    username: process.env.ARCGIS_USERNAME!,
    password: process.env.ARCGIS_PASSWORD!,
    referer: process.env.ARCGIS_REFERER!,
  },
});

export const { POST, GET } = toNextJsHandler(proxy);
ARCGIS_MAP_SERVER_URL=https://gis.example.com/rest/services/Cadastre/MapServer
ARCGIS_TOKEN_URL=https://gis.example.com/arcgis/tokens/generateToken
ARCGIS_USERNAME=replace-with-username
ARCGIS_PASSWORD=replace-with-password
ARCGIS_REFERER=https://app.example.com

Never prefix these values with NEXT_PUBLIC_.

Configuration

| Option | Description | | --- | --- | | mapServerUrl | Absolute ArcGIS URL ending in /MapServer. HTTPS is required except on localhost. | | bearerToken | Server-only static bearer token. | | oauth2.tokenUrl | Server-only ArcGIS OAuth2 token endpoint. HTTPS is required except on localhost. | | oauth2.clientId | Server-only OAuth2 client ID. | | oauth2.clientSecret | Server-only OAuth2 client secret. | | arcgisToken.tokenUrl | Server-only ArcGIS Server generateToken endpoint. HTTPS is required except on localhost. | | arcgisToken.username | Server-only ArcGIS Server username. | | arcgisToken.password | Server-only ArcGIS Server password. | | arcgisToken.referer | HTTPS application URL bound to the generated token and forwarded to the MapServer. Localhost may use HTTP. |

Configure exactly one of bearerToken, oauth2, or arcgisToken.

OAuth2 uses the client_credentials grant. ArcGIS Server authentication posts username, password, client=referer, referer, and f=json to the configured token endpoint.

Acquired tokens are cached in memory per proxy instance and reused until shortly before expiry. Concurrent requests share one token request, failed token requests are not cached, and a MapServer 401 invalidates the token for the next request.

Create the proxy once at route-module scope as shown above. The cache is intentionally process-local: it does not use the Next.js Data Cache or share tokens between server processes or serverless instances.

The MapServer URL cannot contain credentials, a query string, or a fragment. Token and referer URLs cannot contain credentials or fragments.