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

@thepaulin/d_ui

v0.1.2

Published

React drag-and-drop library with position persistence for any JS metaframework

Readme

@thepaulin/d_u

A lightweight React drag-and-drop library with position persistence. Built for any JS metaframework (Next.js, Remix, Gatsby, etc.).

npm install @thepaulin/d_u

Usage

import { DraggableUI, Draggable } from '@thepaulin/d_u';

function App() {
  return (
    <DraggableUI>
      <Draggable id="card-1" defaultPosition={{ x: 100, y: 200 }}>
        <div>Drag me</div>
      </Draggable>
    </DraggableUI>
  );
}

Persistence and drag context are configured via DraggableUI. Drop-in Draggable makes any child element movable.

Features

  • Position persistence — positions saved to localStorage by default; survives page reloads
  • Custom storage — supply your own StorageAdapter for server/DB-backed persistence
  • Two positioning modestransform (no layout shift) or absolute
  • Axis constraint — restrict dragging to x, y, or both
  • Grid snapping — snap to any [column, row] grid
  • Drag handles — restrict drag start to a specific handle element
  • Full event callbacksonDragStart, onDrag, onDragEnd
  • Headless hookuseDraggable for completely custom rendering
  • Imperative controlusePosition to read or update positions outside of drag
  • SSR-safe — no window references on the server
  • Zero runtime deps — only peer dependency on React 16.8+

API

<DraggableUI>

Root provider. Must wrap all Draggable instances.

| Prop | Type | Default | Description | |------|------|---------|-------------| | storageKey | string | 'default' | Key for persisting positions | | storageAdapter | StorageAdapter | localStorage adapter | Custom persistence backend | | positioningMode | 'transform' \| 'absolute' | 'transform' | CSS strategy for positioning | | className | string | — | Class for the wrapper element | | style | CSSProperties | — | Inline styles for the wrapper | | as | ElementType | 'div' | Wrapper element tag |

<Draggable>

Makes its single child element draggable.

| Prop | Type | Default | Description | |------|------|---------|-------------| | id | string | required | Unique identifier | | defaultPosition | { x: number, y: number } | { x: 0, y: 0 } | Initial position | | disabled | boolean | false | Disables dragging | | axis | 'both' \| 'x' \| 'y' | 'both' | Restrict movement axis | | grid | [number, number] | — | Snap grid [column, row] | | zIndex | number | — | Z-index while dragging (via style) | | handle | RefObject<HTMLElement> | — | Element that must be clicked to drag | | onDragStart | (event) => void | — | Called on drag start | | onDrag | (event) => void | — | Called on each drag move | | onDragEnd | (event) => void | — | Called on drag end |

useDraggable(options)

Headless hook — returns { ref, style, onPointerDown, attributes } for fully custom rendering.

usePosition(id, defaultPosition?)

Read and update a draggable's position imperatively. Returns { x, y, setPosition, resetPosition }.

useDragContext()

Access the nearest DraggableUI context. Throws if called outside a provider.

Types

| Export | Description | |--------|-------------| | Position | { x: number, y: number } | | StorageAdapter | { getItem, setItem, removeItem } | | PositioningMode | 'transform' \| 'absolute' | | DragStartEvent | Event payload on drag start | | DragMoveEvent | Event payload during drag | | DragEndEvent | Event payload on drag end |


Developing

git clone https://github.com/thepaulin/d_ui.git
cd d_ui
npm install

Scripts

| Command | Description | |---------|-------------| | npm run dev | Watch mode rebuild | | npm run build | Production build via tsup | | npm test | Run test suite (Vitest) | | npm run test:watch | Watch mode tests | | npm run test:coverage | Test coverage report | | npm run typecheck | TypeScript type check |

Project structure

src/
  components/   — DraggableUI, Draggable
  context/      — DragContext provider
  hooks/        — useDraggable, usePosition, useDragContext
  utils/        — storage, coordinates, guards
  types/        — TypeScript interfaces
  constants.ts  — shared constants

Contributing

  1. Fork the repo and create a feature branch.
  2. Run npm install and npm run dev to start the build watcher.
  3. Write or update tests under src/**/__tests__/.
  4. Run npm test and npm run typecheck — all must pass.
  5. Open a pull request.

The library aims to be minimal. New features should justify their weight. When in doubt, open an issue first to discuss.