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

ek-viewport

v1.3.0

Published

Lightweight, type-safe, and SSR-friendly responsive utilities for React.

Readme

ek-viewport

Lightweight, type-safe, and SSR-friendly responsive utilities for React. Focuses on performance and developer experience.

npm version License: MIT

ek-viewport solves the "Hydration Mismatch" problem in Next.js/SSR apps while providing a declarative API for handling responsive logic.


Features

  • SSR Safe: Works perfectly with Next.js & Remix (no hydration errors)
  • Customizable: Use your own breakpoint values via ViewportProvider
  • Sensors: Track scroll direction, orientation, and window size
  • Debug Tool: Built-in overlay to see active breakpoints in real-time
  • Zero Dependencies: Keeps your bundle size minimal
  • Type Safe: Full TypeScript support for all hooks and components

Installation

npm install ek-viewport
# or
yarn add ek-viewport
# or
pnpm add ek-viewport

Setup (Optional Custom Config)

By default, ek-viewport uses standard Tailwind CSS breakpoints. You can customize them using the ViewportProvider.

import { ViewportProvider } from 'ek-viewport';

const customBreakpoints = {
  md: 800,
  lg: 1100
};

const App = () => (
  <ViewportProvider breakpoints={customBreakpoints}>
    <YourContent />
  </ViewportProvider>
);

Usage

1. Basic Hook: useBreakpoint

Returns true if the viewport is above the specified breakpoint.

import { useBreakpoint } from 'ek-viewport';

const MyComponent = () => {
  const isDesktop = useBreakpoint('lg'); 

  return <div>{isDesktop ? "Desktop View" : "Mobile View"}</div>;
};

2. Declarative Components: Show & Hide

Manage layouts without complex ternary operators.

import { Show, Hide } from 'ek-viewport';

const Navbar = () => (
  <nav>
    <Logo />
    <Show above="md">
      <DesktopMenu />
    </Show>
    <Hide above="md">
      <MobileMenu />
    </Hide>
  </nav>
);

3. Sensors & Utilities

useScrollDirection

Detects if the user is scrolling 'up' or 'down'.

import { useScrollDirection } from 'ek-viewport';

const Header = () => {
  const direction = useScrollDirection();
  return (
    <header className={direction === 'down' ? 'hidden' : 'visible'}>
      ...
    </header>
  );
};

useWindowSize

Track exact pixel dimensions.

import { useWindowSize } from 'ek-viewport';

const MyComponent = () => {
  const { width, height } = useWindowSize();
  
  return <div>Window: {width} x {height}</div>;
};

useOrientation

Detect landscape or portrait mode.

import { useOrientation } from 'ek-viewport';

const MyComponent = () => {
  const { isLandscape } = useOrientation();
  
  return <div>{isLandscape ? 'Landscape' : 'Portrait'}</div>;
};

Developer Experience (Debug Tool)

Stop guessing which breakpoint is active. Drop the DebugOverlay at the root of your app during development.

import { DebugOverlay } from 'ek-viewport';

const App = () => (
  <>
    <DebugOverlay />
    <YourContent />
  </>
);

Default Breakpoints

| Key | Min-Width | |------|-----------| | sm | 640px | | md | 768px | | lg | 1024px | | xl | 1280px | | 2xl | 1536px |


License

MIT © [Your Name/Organization]


Contributing

Contributions, issues and feature requests are welcome!


⭐ Show your support

Give a ⭐️ if this project helped you!