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

@s3nd/react

v0.1.1

Published

React hooks for s3nd transfers: send a snapshot or a file, read a code back, and a sync code input that repairs what the user typed.

Readme

@s3nd/react

npm install size MIT Docs

React hooks for moving a local-first app's data between devices: send a snapshot or a file, read a code back, and an input that repairs the code as the user types it.

npm install @s3nd/react

It never sees a storage credential, and never pulls a storage client. Its whole dependency tree is @s3nd/protocol and nanoid, with React as a peer; the AWS SDK stays on your server, where @s3nd/core runs. That separation is the reason this is its own package.

React 18 or later. Every export is a client hook, and the build carries 'use client', so it drops straight into the Next.js App Router.

Setting it up

Point the provider at wherever you mounted the transfer routes:

import { S3ndProvider } from '@s3nd/react'

export default function Providers({ children }) {
  return <S3ndProvider baseUrl="/api/transfers">{children}</S3ndProvider>
}

Pass headers for a token, or client to bring your own, which is also how you drive it in tests, with no network at all.

Sending

import { useSendTransfer } from '@s3nd/react'

function MoveToAnotherDevice() {
  const { send, transfer, isPending, error } = useSendTransfer()

  return (
    <>
      <button onClick={async () => send(await exportDatabase(), { version: 3 })} disabled={isPending}>
        Move to another device
      </button>

      {transfer && <p>Type this on the other device: {transfer.code}</p>}
      {error && <p>{error.message}</p>}
    </>
  )
}

sendFile takes a File straight off an <input type="file">, keeping its name and type.

Failures land in error rather than rejecting: an event handler should not need a try/catch. The call returns null when it failed, for callers that want to branch.

Receiving

import { useReceiveTransfer, useSyncCodeInput } from '@s3nd/react'

function RestoreFromCode() {
  const input = useSyncCodeInput()
  const { load, transfer, data, notFound, isPending } = useReceiveTransfer<DatabaseDump>()

  return (
    <>
      <input {...input.inputProps} placeholder="K7QP2M4X" />
      <button onClick={() => input.code && load(input.code)} disabled={!input.isComplete || isPending}>
        Look it up
      </button>

      {notFound && <p>Unknown or expired code.</p>}
      {transfer && (
        <>
          <p>
            From {transfer.device}, {new Date(transfer.createdAt).toLocaleString()}
          </p>
          <button onClick={() => importDatabase(data!)}>Replace my data</button>
        </>
      )}
    </>
  )
}

Loading and applying are deliberately separate: only your code knows its own object stores, and the user should see what is about to replace their data before it does.

The code input

useSyncCodeInput does the repair in the browser, before any request: separators dropped, case folded, and O/I/L read as 0/1/1 where the alphabet makes that unambiguous.

const { value, code, isComplete, error, inputProps } = useSyncCodeInput()

What the user typed stays in value, untouched; rewriting the field under the cursor is the one thing that makes these inputs miserable. code is the canonical form to submit, null while what is typed cannot be one. inputProps carries the keyboard and autofill hints a one-time code wants.

Pass the same shape your server configured:

useSyncCodeInput({ length: 4, alphabet: '0123456789' }) // inputProps.inputMode becomes "numeric"

What each hook gives back

| Hook | | | ---------------------- | ---------------------------------------------------------------------------------------------------- | | useSendTransfer() | send, sendFile, transfer, status, isPending, error, reset | | useReceiveTransfer() | load, loadBytes, burn, transfer, data, notFound, status, isPending, error, reset | | useSyncCodeInput() | value, setValue, code, isComplete, error, reset, inputProps | | useTransferClient() | the underlying client, for anything the hooks do not cover |

status is 'idle' | 'pending' | 'success' | 'error'.

Every call aborts the one before it, a late reply from a superseded call is dropped rather than published, and nothing is written after unmount, so a user hammering a button does not end up with whichever request happened to finish last.

License

MIT © Abderrahmane Mouzoune