Packages

Static File Handling Package

A guide to static file handling in Raptor

Installation

To start using the static file handling, simply install into an existing Raptor application via the CLI or, if you are using Deno, import it directly from JSR.

deno add jsr:@raptor/static
bunx jsr add @raptor/static
npx jsr add @raptor/static
yarn dlx jsr add @raptor/static
pnpm dlx jsr add @raptor/static

Configuration

An optional configuration object is available, allowing you to customise your static file handling setup.

import type { Config } from "@raptor/static";
 
export default {
  /**
   * The directory to serve static files from.
   */
  directory: "/public",
} satisfies Config;

For more information about the config-driven setup, see Configuration.

Usage

The static handler supports a configurable path, relative to the current working directory.

import static from "@raptor/static";
import { Kernel } from "@raptor/kernel";
 
import config from "./static.config.ts";
 
const app = new Kernel();
 
app.use(static(config));
 
app.use(
  () => `
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="/css/style.css">
</head>
<body>
  <h1>It's a UNIX System! I know this!</h1>
</body>
</html>
`,
);
 
app.serve();

The code above will render an HTML page and load in the stylesheet with the correct headers.

© 2026 Raptor