/Wiki/sources/honojs__hono/2026/https-hono-dev-llms-full-txt-serve-static-files-2ddaa6b15818-serve-static-files-s0458-c0000.md
Serve static files (1) - hono-docs
Serve static files (1) Source evidence: /Sources/raw/honojs hono/honojs hono.md Canonical citation: https://hono.dev/llms full.txt serve static files Summary...
Serve static files (1)
Source evidence: /Sources/raw/honojshono/honojshono.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.pngIf 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: