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

@uploadkitdev/next

v0.2.1

Published

UploadKit Next.js server integration — createUploadKitHandler, file router, presigned URL generation, and Express/Fastify/Hono adapters.

Readme

@uploadkitdev/next

npm version npm downloads License: MIT CI

Next.js App Router adapter for UploadKit with typed file routes.

Features

  • File router pattern — define upload rules once, enforce them everywhere
  • End-to-end type safety — route names are inferred; mismatches are caught at compile time
  • Middleware support — authenticate and enrich uploads in a single function
  • BYOS compatible — swap to your own S3/R2 bucket with zero frontend changes
  • App Router native — returns a standard Next.js Route Handler; no custom server needed

Install

# npm
npm install @uploadkitdev/next

# pnpm
pnpm add @uploadkitdev/next

# yarn
yarn add @uploadkitdev/next

Peer dependency: next >= 14

Quickstart

1. Define your file router

// lib/upload.ts
import { createUploadKitHandler } from '@uploadkitdev/next';
import type { FileRouter } from '@uploadkitdev/next';

export const fileRouter = {
  imageUploader: {
    maxFileSize: '4MB',
    maxFileCount: 10,
    allowedTypes: ['image/jpeg', 'image/png', 'image/webp'],
    middleware: async ({ req }) => {
      // Authenticate the user, return metadata attached to every upload
      const user = await getCurrentUser(req);
      if (!user) throw new Error('Unauthorized');
      return { userId: user.id };
    },
  },

  documentUploader: {
    maxFileSize: '16MB',
    allowedTypes: ['application/pdf'],
  },
} satisfies FileRouter;

export type OurFileRouter = typeof fileRouter;

2. Create the route handler

// app/api/upload/route.ts
import { createUploadKitHandler } from '@uploadkitdev/next';
import { fileRouter } from '@/lib/upload';

const { GET, POST } = createUploadKitHandler({
  router: fileRouter,
  apiKey: process.env.UPLOADKIT_API_KEY!,
});

export { GET, POST };

3. Use in your React components

// In your client component (with @uploadkitdev/react installed)
import { UploadButton } from '@uploadkitdev/react';

<UploadButton route="imageUploader" endpoint="/api/upload" />

API Overview

createUploadKitHandler(config)

Returns { GET, POST } route handlers for Next.js App Router.

| Option | Type | Description | |--------|------|-------------| | router | FileRouter | Your file router definition | | apiKey | string | UploadKit API key (uk_live_...) |

FileRouter type

A record where each key is a route name and the value is a RouteConfig:

| Field | Type | Description | |-------|------|-------------| | maxFileSize | string | e.g. "4MB", "100KB" | | maxFileCount | number | Max files per upload request | | allowedTypes | string[] | MIME types allowed | | middleware | async ({ req }) => metadata | Auth + metadata function |

generateReactHelpers(router)

Generates type-safe component wrappers that infer route names from your FileRouter.

import { generateReactHelpers } from '@uploadkitdev/next';
import type { OurFileRouter } from '@/lib/upload';

export const { UploadButton, UploadDropzone } =
  generateReactHelpers<OurFileRouter>();

BYOS (Bring Your Own Storage)

Pass your own S3-compatible credentials in the handler config. Presigned URL generation happens server-side — credentials never reach the browser.

const { GET, POST } = createUploadKitHandler({
  router: fileRouter,
  apiKey: process.env.UPLOADKIT_API_KEY!,
  storage: {
    endpoint: process.env.R2_ENDPOINT!,
    accessKeyId: process.env.R2_ACCESS_KEY_ID!,
    secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
    bucket: process.env.R2_BUCKET!,
  },
});

Links

License

MIT