Storage

Local (disk)

Zero-config storage that writes uploads to the local disk.

CloudSelf-Hosted
⚠️ Not durable✅ Supported

The Local adapter ships with @vitnode/core — no extra package or cloud account needed. It writes files to a public/uploads directory and serves them as static files.

Not durable on serverless

Serverless platforms (e.g. Vercel) have an ephemeral, read-only filesystem, so locally stored files are lost between deploys and instances. Use a cloud adapter (S3 / R2 or Supabase) in those environments.

Usage

Import the adapter

vitnode.api.config.ts
import { LocalStorageAdapter } from "@vitnode/core/api/adapters/storage/local";
import { buildApiConfig } from "@vitnode/core/vitnode.config";

export const vitNodeApiConfig = buildApiConfig({
  storage: {
    adapter: LocalStorageAdapter(),
  },
});

Serve the files

On the standalone Node API, mount the adapter's static descriptor with Hono's serveStatic before VitNodeAPI so uploads are served at /api/uploads/*:

src/index.ts
import { serveStatic } from "@hono/node-server/serve-static";

const staticStorage = vitNodeApiConfig.storage?.adapter?.static;
if (staticStorage) {
  app.get(
    staticStorage.mountPath,
    serveStatic({
      root: staticStorage.root,
      rewriteRequestPath: path => path.replace(staticStorage.stripPrefix, ""),
    }),
  );
}

VitNodeAPI({ app, vitNodeApiConfig });

Inside a Next.js app the public/ directory is already served at the site root, so no serveStatic is needed — just point the adapter's public path at it:

vitnode.api.config.ts
adapter: LocalStorageAdapter({ publicPath: "/uploads" }),

Options

Prop

Type

On this page