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

react-device-lab

v1.1.2

Published

Accessible React components for previewing web applications across named device viewports.

Readme

React Device Lab

react-device-lab is an open-source React toolkit for reviewing responsive web applications in exact, named CSS viewports. It combines an iframe-backed preview engine, 85 device profiles, independent authored frames, a searchable catalog, orientation and display scaling, route tools, safe-area visualization, and configurable browser-environment scenarios.

It is a responsive application preview tool, not an iOS, Android, browser-engine, or hardware emulator. Use it to catch layout and interaction problems early; verify OS-owned behavior on real devices and platform tooling.

Light React Device Lab workspace

Dark React Device Lab workspace

Narrow stacked React Device Lab workspace

Features

  • Exact iframe viewport dimensions with portrait and landscape orientation.
  • Fit, 50%, 75%, 100%, and custom visual scale without changing media-query dimensions.
  • 85 phones, foldables, tablets, laptops, desktops, and ultrawide profiles.
  • Independently authored CSS/React skins with notches, camera cutouts, buttons, fold creases, laptop bases, and monitor stands.
  • Same-origin SPA route inspection and an exact-origin postMessage bridge for cooperating cross-origin applications.
  • Searchable/grouped device selection, custom viewports, destinations, reload, and open-in-new-tab actions.
  • Full-screen desktop workspace with independent stage/panel scrolling and a responsive narrow layout.
  • Light/dark themes and product-neutral --rdl-* CSS custom properties.
  • Optional safe-area, virtual-keyboard, locale, direction, text-scale, accessibility, pointer, fold, and permission scenarios.
  • SSR-safe ESM imports, TypeScript declarations, and React 18/19 peer support.

Installation

npm install react-device-lab

Import the stylesheet once in the application that hosts the lab.

import { DevicePreviewLab } from "react-device-lab";
import "react-device-lab/styles.css";

export function PreviewRoute() {
  return (
    <DevicePreviewLab
      src="http://localhost:3000"
    />
  );
}

The target URL must permit framing. For production targets, configure a narrow Content Security Policy frame-ancestors allow-list and review the security policy and iframe guidance.

Destinations and controlled state

import {
  DevicePreviewLab,
  type PreviewRouteState,
} from "react-device-lab";
import "react-device-lab/styles.css";

const destinations = [
  { id: "home", label: "Home", src: "http://localhost:3000/" },
  { id: "settings", label: "Settings", src: "http://localhost:3000/settings" },
];

export function ReviewWorkspace() {
  const handleRoute = (route: PreviewRouteState) => {
    console.info("Embedded route:", route.pathname);
  };

  return (
    <DevicePreviewLab
      defaultDeviceId="iphone-17-pro"
      destinations={destinations}
      onRouteChange={handleRoute}
      src={destinations[0].src}
      title="Responsive review"
    />
  );
}

The embedded application remains authoritative for live SPA navigation. onRouteChange observes normalized same-origin or bridge route state without remounting the iframe. Use src or destinations for top-level navigation.

Rendering React content

Pass React children instead of src to render through an iframe portal. CSS media queries then use the iframe viewport, unlike a host-width <div>.

<DevicePreviewLab
  defaultDeviceId="pixel-10"
  portalStyles="body { margin: 0; font-family: system-ui; }"
>
  <YourResponsiveApplication />
</DevicePreviewLab>

Portal component closures still run in the host JavaScript realm. Read iframe modes and fidelity before choosing this mode.

Documentation

The repository also generates a searchable HTML reference site from the TSDoc comments on the public TypeScript API and includes every guide above in the same navigation:

npm run docs:build

Open site/index.html after the build. The generated site/ directory is intentionally ignored; source comments and Markdown remain authoritative. For live local navigation and search, run npm run docs:serve and open http://127.0.0.1:4176.

Acknowledgement

Flutter Device Preview demonstrated how valuable an integrated device-preview workflow can be and inspired the interaction category. This repository is an independent React/web implementation: it does not copy that project’s code, data, or assets.

Status

The first public release, 1.0.0, shipped on 2026-07-26; the changelog tracks the current version. No package publication is performed by ordinary CI, and a maintainer must explicitly publish a matching GitHub Release before the trusted-publishing workflow can run.