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

@summonair/foldify

v0.1.2

Published

Seamless React components and hooks for foldable devices and dual-screens.

Readme

📱 foldify

Seamless React components and hooks for foldable devices and dual-screens.

As hardware evolves, web applications need to adapt to new form factors like the Samsung Galaxy Z Fold, Google Pixel Fold, Microsoft Surface Duo, and now Apple's iPhone Duo. foldify bridges the gap between React's declarative nature and the emerging W3C Viewport Segments and Device Posture APIs.

Stop worrying about hinges swallowing your content, and start building beautiful, book-like experiences.

https://github.com/user-attachments/assets/777d6d8c-c790-47aa-99a5-d74e3f2d14e1

📦 Installation

npm install @summonair/foldify

🚀 Usage

Quick start with <FoldGrid>

import { FoldGrid } from '@summonair/foldify';

function App() {
  return (
    <FoldGrid fallbackDirection="column">
      <Sidebar />
      <MainContent />
    </FoldGrid>
  );
}

On a foldable device, <Sidebar> lands on the first screen and <MainContent> on the second, with the gap between them sized to the real hinge. On a normal single-screen device, they just stack in a column (or row, your call).

Keeping content out of the hinge

import { HingeSafeArea } from '@summonair/foldify';

function Toolbar() {
  return (
    <HingeSafeArea>
      <button onClick={save}>Save</button>
    </HingeSafeArea>
  );
}

Building custom layouts with the hooks

import { useViewportSegments, useDevicePosture, useIsFoldable } from '@summonair/foldify';

function Reader() {
  const segments = useViewportSegments();
  const posture = useDevicePosture();
  const isFoldable = useIsFoldable();

  if (!isFoldable) {
    return <SinglePaneReader />;
  }

  return posture === 'folded'
    ? <TableTopReader segments={segments} />
    : <TwoPageReader segments={segments} />;
}

Every hook and component here works exactly the same on a browser that doesn't support the underlying APIs — see Browser Support below.

🛠️ The Hooks API

useViewportSegments()

Returns an array of screen segments. On a standard phone, this returns one segment. On a dual-screen device, it returns two DOMRect objects detailing the dimensions of each screen.

useDevicePosture()

Know if the device is flat on a table (continuous) or bent like a laptop (folded).

🧩 Layout Components

<FoldGrid>

Automatically snaps content to separate screens if a physical fold or hinge is detected. If on a normal device, it stacks them based on your fallback props.

<HingeSafeArea>

Ensure critical UI isn't lost in the physical seam of the device. This component automatically applies padding equivalent to the hinge width.

⚠️ Browser Support

foldify relies on emerging W3C specifications. It is designed with graceful degradation and is completely safe to use in all modern browsers.

🤝 Contributing

Contributions are welcome — see CONTRIBUTING.md for setup instructions and guidelines.

📄 License

MIT

☕ Support

If foldify saved you some hinge-related headaches, consider buying me a coffee.