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

Usage

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

import static from "@raptor/static";
import { Kernel, Context } from "@raptor/kernel";
 
const app = new Kernel();
 
app.use(static({
  staticFileDirectory: "public"
}));
 
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