
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@uploadkitdev/next
Advanced tools
UploadKit Next.js server integration — createUploadKitHandler, file router, presigned URL generation, and Express/Fastify/Hono adapters.
Next.js App Router adapter for UploadKit with typed file routes.
# npm
npm install @uploadkitdev/next
# pnpm
pnpm add @uploadkitdev/next
# yarn
yarn add @uploadkitdev/next
Peer dependency: next >= 14
// 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;
// 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 };
// In your client component (with @uploadkitdev/react installed)
import { UploadButton } from '@uploadkitdev/react';
<UploadButton route="imageUploader" endpoint="/api/upload" />
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 typeA 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>();
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!,
},
});
MIT
FAQs
UploadKit Next.js server integration — createUploadKitHandler, file router, presigned URL generation, and Express/Fastify/Hono adapters.
The npm package @uploadkitdev/next receives a total of 1 weekly downloads. As such, @uploadkitdev/next popularity was classified as not popular.
We found that @uploadkitdev/next demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.