TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/elysiajs/documentation/llms.txt
Use this file to discover all available pages before exploring further.
@elysia/static plugin serves static files and folders from your Elysia server. By default it exposes the public/ directory at the /public URL prefix.
Installation
Basic usage
/public/takodachi.png/public/nested/takodachi.png
Configuration
assets
Default: 'public'
Path to the local directory to expose as static files.
prefix
Default: '/public'
URL prefix under which static files are served.
ignorePatterns
Default: []
List of file patterns to exclude from being served.
headers
Default: {}
Custom response headers applied to every static file response:
indexHTML
Default: false
When true, the index.html file from the static directory is served for any request that doesn’t match a route or an existing static file. Useful for single-page applications.
staticLimit
Default: 1024
The maximum number of static file paths registered eagerly in the router. When the number of files exceeds this limit, additional paths are added lazily to reduce startup memory usage.
alwaysStatic
Default: false
When true, all static file paths are registered in the router at startup, ignoring staticLimit. Use this when you want predictable routing behavior and memory is not a concern.
Serving a single file
For serving a single file rather than a directory, use the built-infile helper instead of the static plugin: