title | sidebar_label | sidebar_position | pagination_label |
---|---|---|---|
Overview |
Module Overview |
0 |
Module: Assets |
Keywork provides static asset helpers as KeyworkRouter
Middleware.
Depending on your deployment setup, how you manage your static assets
may vary.
If you're using Cloudflare Pages, static assets will be configured in your
Pages build settings. You'll need CloudflarePagesAssetRouter
:
import { YourAppRoutes } from '@local/worker/routers/your-app-routes'
import { KeyworkRouter } from 'keywork/router'
// highlight-next-line
import { CloudflarePagesAssetRouter } from 'keywork/assets'
// Create a router to receive all incoming requests...
const app = new KeyworkRouter({
// A display name used for debugging and log messages.
displayName: 'Example Keywork App',
// Here we combine our routers...
middleware: [
YourAppRoutes,
// highlight-next-line
new CloudflarePagesAssetRouter(),
],
})
If you're using Worker Sites, static assets are configured via your wrangler.toml
file.
You'll instead need WorkerSitesAssetRouter
import { YourAppRoutes } from '@local/worker/routers/your-app-routes'
import { KeyworkRouter } from 'keywork/router'
// highlight-next-line
import { WorkerSitesAssetRouter } from 'keywork/assets'
// highlight-next-line
import manifestJSON from '__STATIC_CONTENT_MANIFEST'
// Create a router to receive all incoming requests...
const app = new KeyworkRouter({
// A display name used for debugging and log messages.
displayName: 'Example Keywork App',
// Here we combine our routers...
middleware: [
YourAppRoutes,
// highlight-next-line
new WorkerSitesAssetRouter(manifestJSON),
],
})