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-adaptive-render

v1.0.2

Published

Device-aware adaptive UI rendering for React and Next.js — SSR safe, lazy loading, tree-shakable

Readme

react-adaptive-render

Device-aware adaptive UI rendering for React & Next.js.
SSR safe · Lazy loading · Tree-shakable · TypeScript · ~2KB

npm version bundle size license


Why

CSS media queries style the same component differently. This library renders completely different components per device — while lazy-loading only the one that's needed.

| Feature | CSS media queries | react-adaptive-render | |---|---|---| | Responsive styles | yes | yes | | Different component trees | no | yes | | Lazy / code-split loading | no | yes | | SSR device hint (no flash) | no | yes | | Custom breakpoints | no | yes |


Install

npm install react-adaptive-render
# or
yarn add react-adaptive-render

Quick Start

1. <Adaptive> — render different JSX per device

import { Adaptive } from "react-adaptive-render"

export function Navbar() {
  return (
    <Adaptive
      mobile={<MobileNavbar />}
      tablet={<TabletNavbar />}
      desktop={<DesktopNavbar />}
    />
  )
}

Missing variants fall back gracefully: tablet → desktop, mobile → tablet → desktop.


2. adaptiveDynamic — lazy load separate bundles per device

import { adaptiveDynamic } from "react-adaptive-render"

const Layout = adaptiveDynamic({
  mobile:  () => import("./mobile/Layout"),
  tablet:  () => import("./tablet/Layout"),
  desktop: () => import("./desktop/Layout"),
})

export default function Page() {
  return <Layout />
}

Only the matching bundle is downloaded. Mobile users never download desktop code.


3. useDevice — simple hook

import { useDevice } from "react-adaptive-render"

function Sidebar() {
  const device = useDevice()
  // "mobile" | "tablet" | "desktop"

  if (device === "mobile") return <Drawer />
  return <Sidebar />
}

4. useAdaptive — full device info

import { useAdaptive } from "react-adaptive-render"

function Banner() {
  const { isMobile, orientation, width } = useAdaptive()

  return (
    <div>
      {isMobile && orientation === "portrait" ? "Portrait mobile" : "Other"}
      — width: {width}px
    </div>
  )
}

5. useBreakpoint — arbitrary min/max check

import { useBreakpoint } from "react-adaptive-render"

const isWide = useBreakpoint({ minWidth: 1200 })
const isSmall = useBreakpoint({ maxWidth: 480 })

Next.js SSR Setup (prevents hydration flash)

In app/layout.tsx (App Router):

import { headers } from "next/headers"
import { AdaptiveProvider, detectDeviceSSR } from "react-adaptive-render"

export default function RootLayout({ children }) {
  const ua = headers().get("user-agent") ?? ""
  const ssrDevice = detectDeviceSSR(ua)

  return (
    <html>
      <body>
        <AdaptiveProvider ssrDevice={ssrDevice}>
          {children}
        </AdaptiveProvider>
      </body>
    </html>
  )
}

Custom Breakpoints

<AdaptiveProvider
  breakpoints={{
    mobile: 640,   // ≤ 640px  → mobile
    tablet: 1024,  // ≤ 1024px → tablet
                   // > 1024px → desktop
  }}
>
  {children}
</AdaptiveProvider>

API Reference

Components

| Name | Props | Description | |---|---|---| | <Adaptive> | mobile? tablet? desktop? fallback? | Renders matching ReactNode | | <AdaptiveProvider> | breakpoints? ssrDevice? | Global config provider |

Functions

| Name | Signature | Description | |---|---|---| | adaptiveDynamic | (loaders, fallback?) => Component | Lazy device-split component | | detectDeviceSSR | (userAgent: string) => DeviceType | SSR user-agent detection |

Hooks

| Name | Returns | Description | |---|---|---| | useDevice() | DeviceType | Current device string | | useAdaptive() | DeviceInfo | Full device info object | | useBreakpoint(opts) | boolean | Matches min/max width range |


TypeScript

All types are exported:

import type {
  DeviceType,        // "mobile" | "tablet" | "desktop"
  Orientation,       // "portrait" | "landscape"
  Breakpoints,       // { mobile: number; tablet: number }
  DeviceInfo,        // full useAdaptive() return type
  AdaptiveProps,
} from "react-adaptive-render"

License

MIT