Sign In

@uploadkitdev/core

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uploadkitdev/core

UploadKit core SDK — type-safe presigned URL client for browser, Node and Edge runtimes.

latest
Source
npmnpm
Version
0.2.1
Version published
Weekly downloads
12
-36.84%
Maintainers
1
Weekly downloads
 
Created
Source

@uploadkitdev/core

npm version npm downloads License: MIT CI Bundle size

Lightweight TypeScript client for UploadKit file uploads.

Features

  • Presigned URL uploads — files go directly to Cloudflare R2, never through your server
  • Automatic multipart — files over 10 MB are split and uploaded in parallel
  • Progress tracking — per-file progress callbacks with percentage
  • Retry with backoff — configurable automatic retry on transient failures
  • Abort support — cancel in-flight uploads with AbortSignal
  • BYOS compatible — works with Bring Your Own Storage configuration
  • Zero dependencies — ships with no runtime deps; @uploadkitdev/shared is bundled

Install

# npm
npm install @uploadkitdev/core

# pnpm
pnpm add @uploadkitdev/core

# yarn
yarn add @uploadkitdev/core

Quickstart

import { createUploadKit } from '@uploadkitdev/core';

const client = createUploadKit({ apiKey: 'uk_live_...' });

// Pick a file (browser File object)
const file = document.querySelector<HTMLInputElement>('#file')!.files![0];

const result = await client.upload({
  file,
  route: 'imageUploader', // matches your file route name
  onProgress: (pct) => console.log(`${pct}% uploaded`),
});

console.log(result.url); // https://cdn.uploadkit.dev/...

API Overview

createUploadKit(config)

Factory function that returns an UploadKitClient instance.

OptionTypeDefaultDescription
apiKeystring(required)API key prefixed with uk_live_ or uk_test_
baseUrlstringhttps://api.uploadkit.devOverride for self-hosted or testing
maxRetriesnumber3Number of retry attempts on transient failures

client.upload(options)

Upload a single file. Returns a Promise<UploadResult>.

OptionTypeDescription
fileFileBrowser File object to upload
routestringFile route name defined in your handler
metadataRecord<string, unknown>Optional metadata stored with the file
onProgress(pct: number) => voidProgress callback (0–100)
signalAbortSignalCancel the upload via AbortController

client.listFiles(options?)

List files for the project linked to your API key.

OptionTypeDescription
limitnumberMax files to return (default: 20)
cursorstringPagination cursor from previous response

Returns Promise<{ files: UploadResult[]; nextCursor?: string }>.

client.deleteFile(key)

Permanently delete a file by its storage key. Returns Promise<void>.

Abort Uploads

const controller = new AbortController();

// Cancel after 10 seconds
setTimeout(() => controller.abort(), 10_000);

await client.upload({
  file,
  route: 'imageUploader',
  signal: controller.signal,
});

License

MIT

Keywords

upload

FAQs

Package last updated on 10 Apr 2026

Did you know?

Socket

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.

Install

Related posts