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

sel-custom-esri-print

v0.0.5

Published

## Overview

Readme

PrintWidget Component

Overview

The PrintWidget React component integrates Esri's Print widget into your application. It allows users to export maps in various formats using a specified print service URL. The widget is rendered in a designated container and is attached to an Esri View instance (e.g., View or SceneView).


Features

  • Renders the Esri Print widget into a specified container.
  • Supports custom printServiceUrl for either public or organization-hosted print services.
  • Automatically cleans up resources on component unmount.

Requirements

  • Esri ArcGIS API for JavaScript v4.x.
  • A valid printServiceUrl. Use the Esri public service or a custom service from your portal.

Installation

  1. Install the Esri ArcGIS API for JavaScript dependencies:

    npm install @arcgis/core
    
    2.	Add the component to your project:
    •	Save the component code as PrintWidget.tsx in your project.

Props

• container (string): The ID of the HTML element where the Print widget will be rendered. • printServiceUrl (string): The URL to the print service. You can use the Esri public service or an organization-hosted service. • view (__esri.View): The Esri View instance (e.g., MapView or SceneView) where the widget will be attached.


Usage

Example

import React, { useRef, useEffect, useState } from "react";
import MapView from "@arcgis/core/views/MapView";
import Map from "@arcgis/core/Map";
import PrintWidget from "./PrintWidget";

const App = () => {
  const mapDiv = useRef < HTMLDivElement > null; // Map container reference
  const [view, setView] = (useState < __esri.MapView) | (null > null);

  useEffect(() => {
    if (!mapDiv.current) return;

    const map = new Map({
      basemap: "streets-navigation-vector",
    });

    const mapView = new MapView({
      container: mapDiv.current,
      map: map,
      center: [-118.805, 34.027], // Longitude, latitude
      zoom: 13,
    });

    setView(mapView);

    return () => {
      mapView.destroy();
    };
  }, []);

  return (
    <div style={{ display: "flex", height: "100vh" }}>
      <div ref={mapDiv} style={{ flex: 1 }}></div>
      <div
        id="print-widget-container"
        style={{ width: "300px", padding: "10px" }}
      ></div>
      {view && (
        <PrintWidget
          container="print-widget-container"
          printServiceUrl="https://utility.arcgisonline.com/ArcGIS/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"
          view={view}
        />
      )}
    </div>
  );
};

export default App;

Customization

Using a Custom printServiceUrl

Replace the printServiceUrl with the endpoint of your organization-hosted print service:

printServiceUrl="https://<your-portal>/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"

Styling the Widget

Customize the widget’s appearance using CSS by targeting the container element.

Cleanup and Notes

• The widget automatically cleans up on component unmount by calling printWidget.destroy(). • Ensure the container prop corresponds to a valid HTML element ID.


Troubleshooting

Widget Not Rendering

• Check that the container ID matches an existing element in your DOM. • Ensure the view prop is correctly initialized.

Slow Loading

• Preload resources like @arcgis/core/widgets/Print and @arcgis/core/widgets/Print.css. • Ensure your printServiceUrl is accessible and responds quickly.

This component encapsulates Esri’s Print widget for efficient use in React applications, simplifying the integration process.