/Knowledge/sources/honojs__hono/llms-full/node-js-serve-static-files--f20e31bf8f17.md
Node.js: Serve static files - hono-docs
Node.js: Serve static files Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt serve static files Summary...
Node.js: Serve static files
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#serve-static-files
Summary
You can use serveStatic to serve static files from the local file system. For example, suppose the directory structure is as follows: sh ./ ├── favicon.ico ├── index.ts └── static ├── hello.txt └── image.png If a request to the...
Content
You can use serveStatic to serve static files from the local file system. For example, suppose the directory structure is as follows:
./
├── favicon.ico
├── index.ts
└── static
├── hello.txt
└── image.png
If a request to the path /static/* comes in and you want to return a file under ./static, you can write the following:
import { serveStatic } from '@hono/node-server/serve-static'
app.use('/static/*', serveStatic({ root: './' }))
::: warning
The root option resolves paths relative to the current working directory (process.cwd()). This means the behavior depends on where you run your Node.js process from, not where your source file is located. If you start your server from a different directory, file resolution may fail.
For reliable path resolution that always points to the same directory as your source file, use import.meta.url:
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#serve-static-files",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Node.js > Serve static files (1)",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 458,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "Node.js: Serve static files",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}