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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@deckgl-fiber-renderer/dom

v1.4.0

Published

A React renderer for Deck.gl

Readme

Deckgl Fiber Renderer

Deckgl Fiber Renderer

A React renderer for deck.gl.

[!IMPORTANT] Requires react: 19.0.0 and @deck.gl/*: ^9.1.0

Getting Started

Install @deckgl-fiber-renderer:

npm i @deckgl-fiber-renderer/dom

Install peer dependencies:

npm i react react-dom @deck.gl/core @deck.gl/layers @deck.gl/geo-layers @deck.gl/mesh-layers @deck.gl/mapbox react-map-gl

Create a standalone map:

import { Deckgl, useDeckgl } from '@deckgl-fiber-renderer/dom';
import { Map, useControl } from 'react-map-gl/maplibre';

const INITIAL_VIEW_STATE = {
  longitude: -77.0369,
  latitude: 38.9072,
  zoom: 4,
};

const MAP_STYLE =
  'https://tiles.basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json';

function BasemapSync() {
  const deckglInstance = useDeckgl();
  useControl(() => deckglInstance);

  return null;
}

function DeckglMap() {
  return (
    <Deckgl interleaved>
      <BasemapSync />
      <scatterplotLayer id="example" ... />
    </Deckgl>
}

function Basemap({ children }) {
  return (
    <Map initialViewState={INITIAL_VIEW_STATE} mapStyle={MAP_STYLE}>
      {children}
    </Map>
  )
}

function App() {
  return (
    <Basemap>
      <DeckglMap />
    </Basemap>
  )
}

createRoot(document.getElementById('root')).render(<App />);

Out of the box all layers and views from @deck.gl/core, @deck.gl/geo-layers, @deck.gl/layers, and @deck.gl/mesh-layers are available right away with no additional setup and full intellisense.


Examples


Features

  • You can just think in React, all best practices you would apply normally in your code are applicable with @deckgl-fiber-renderer
  • No performance penalties, it is the same as using deck.gl directly
  • No limitations with regards to children composition or structure
  • Render layers at any depth of the @deckgl-fiber-renderer tree
  • Leverage hooks in components that render layers
  • Hot module reload support
  • Render Views as components
  • Custom layers are supported
  • Automatic resource cleanup when <Deckgl /> unmounts from tree
  • Overlaid and Interleaved support for Mapbox/Maplibre
  • Full TypeScript support for JSX elements

Limitations

  • Interleaving DOM based elements like <div /> inside of the <Deckgl /> component tree is not supported.
  • The <Map /> component from react-map-gl/* cannot be rendered as a child inside of the <Deckgl /> component tree. However, you can wrap the <Deckgl /> component with the <Map /> component. See below for examples.

Accessing the Deck.gl Instance

You can utilize the useDeckgl hook in any host context, meaning that it is not restricted to just the children of <Deckgl />. You can leverage inside of regular react-dom areas of your application as well.

import { useDeckgl } from '@deckgl-fiber-renderer/dom';

function MyComponent() {
  // Will automatically update once Deckgl is initialized
  const deckglInstance = useDeckgl();

  useEffect(() => {
    // Recommended to always check to make sure it exists before using
    if (deckglInstance) {
      ...
    }
  }, []);

  return ...
}

Basemap Integration

[!CAUTION] The <Map /> component from react-map-gl/* cannot be rendered as a child inside of the <Deckgl /> component tree. However, you can wrap the <Deckgl /> component with the <Map /> component. The @deck.gl/mapbox overlay is implicitly included in @react-fiber-renderer/dom and will work out of the box if you pass an interleave prop to the <Deckgl /> component.

  • Example with react-map-gl component
  • Example with maplibre-gl standalone

Different Views

[!IMPORTANT] There is no automatic layer filtering applied based on what View it is nested under in the tree. However, this is something we may add in the future as an opt-in feature.

All of the baked in Views are supported:

<Deckgl ... >
  <mapView id="main" ... >
    <scatterplotLayer id="thing" ... />
  </mapView>
</Deckgl>
<Deckgl ... >
  <orthographicView id="main" ... >
    <scatterplotLayer id="thing" ... />
  </orthographicView>
</Deckgl>

Custom Layers

[!NOTE] This code is included in the examples/custom-layer example.

Adding custom layers to @deckg-fiber-renderer is straightforward. First create a file that contains the custom layer:

// custom-layer.ts
import { CompositeLayer, type DefaultProps } from '@deck.gl/core';
import { ScatterplotLayer, type ScatterplotLayerProps } from '@deck.gl/layers';

export type CustomLayerProps = ScatterplotLayerProps & {
  scaler: number;
};

export class CustomLayer extends CompositeLayer<CustomLayerProps> {
  static layerName = 'CustomLayer';
  static defaultProps: DefaultProps<CustomLayerProps> = {
    scaler: 1.0,
  };

  renderLayers() {
    const props = this.props;

    return [
      new ScatterplotLayer(
        this.getSubLayerProps({
          ...props,
          id: 'scaled',
          data: props.data,
          radiusScale: props.scaler,
          opacity: 0.25,
        }),
      ),
      new ScatterplotLayer(
        this.getSubLayerProps({
          ...props,
          data: props.data,
          id: 'not-scaled',
        }),
      ),
    ];
  }
}

If you are using TypeScript add the following at the bottom of the file to make TypeScript & React aware of this custom JSX element:

// Make TypeScript & React aware of this custom JSX element
declare global {
  namespace React {
    namespace JSX {
      interface IntrinsicElements {
        customLayer: CustomLayerProps;
      }
    }
  }
}

Next create a file in your app that will act as the central hub for adding additional layers to the reconciler. This file needs to imported in a root level file that is always executed (like a Nextjs page/layout). More optimally you can import it nearest to the root of where you are rendering <Deckgl />:

// side-effects.ts
import { extend } from '@deckgl-fiber-renderer/dom';
import { CustomLayer } from './path/to/my-custom-layer';

// Add custom layer(s) to reconciler
extend({
  // jsx elements are transformed to PascalCase behind the scenes
  // so `<customLayer />` becomes `new CustomLayer()`
  CustomLayer, 
});

Now you can use this layer anywhere in your JSX:

<Deckgl ... >
  <customLayer ... />
</Deckgl>

If you included the TypeScript snippet, it will also have full intellisense support and type safety.