Import
Functions
toSSG()
Generates static files from a Hono application.Hono
required
The Hono application instance to generate static files from
FileSystemModule
required
File system module with
writeFile and mkdir methods (e.g., Node.js fs/promises)ToSSGOptions
Configuration options for static generation
Promise<ToSSGResult>
Result object containing:
success: boolean indicating if generation succeededfiles: array of generated file pathserror: Error object if generation failed
ssgParams()
Middleware to define parameters for dynamic routes during SSG.SSGParams | Function
required
Either an array of parameter objects or a function that returns them
MiddlewareHandler
Middleware that provides parameters for static generation
isSSGContext()
Checks if the current request is running in SSG context.Context
required
The Hono context object
boolean
true if running in SSG context, false otherwisedisableSSG()
Middleware to prevent a route from being statically generated.MiddlewareHandler
Middleware that disables SSG for the route
onlySSG()
Middleware to make a route only available during SSG (returns 404 at runtime).MiddlewareHandler
Middleware that makes the route SSG-only
fetchRoutesContent()
Generator function that fetches content for all routes.Hono
required
The Hono application instance
BeforeRequestHook
Hook called before each request
AfterResponseHook
Hook called after each response
number
Number of concurrent requests (default: 2)
Generator
Generator yielding Promises that resolve to route content
saveContentToFile()
Saves content to a file.Promise<object>
required
Promise resolving to content data
FileSystemModule
required
File system module
string
required
Output directory path
Record<string, string>
Custom MIME type to file extension mapping
Promise<string | undefined>
Path to the saved file, or undefined if save was skipped
Types
ToSSGOptions
ToSSGResult
SSGParams
FileSystemModule
Advanced Usage
Custom Extension Mapping
Build Script Example
Dynamic Routes with Database
File Output
Generated files follow these patterns:/→/index.html/about→/about.html/about/→/about/index.html/api/data→/api/data.json(for JSON responses)/feed.xml→/feed.xml