Enhance Routing

Enhance uses a file-system based router. When a file is added to the pages or api directory, it’s automatically available as a route.


Dynamic Route Segments

To match a dynamic segment, you can use the $segment syntax. This allows you to match named parameters.

app/pages/docs/$lang.mjs β†’ /docs/:lang β†’ eg. (/docs/en)
app/pages/blog/$slug.mjs β†’ /blog/:slug β†’ eg. (/blog/hello-world)
app/api/users/$id.mjs β†’ /users/:id β†’ eg. (/users/axol)

Catch All Routes

To match all routes past a point in a URL, you can use the $$ syntax.

app/pages/docs/$$.mjs β†’ /docs/:path β†’ eg. (/docs/concepts/routing/)
app/pages/docs/$$.mjs β†’ /docs/:path β†’ eg. (/docs/concepts/styling/)

API Routes

Enhance API routes are backend JSON routes designed for seamless clientside progressive enhancement. API routes are defined under app/api and follow the same file based routing conventions as app/pages.

export async function get (req) {
  return {
    json: {
      favorties: ['coffee crisp', 'smarties']

Community Resources

Visit Enhance on GitHub.
Join our Discord server to chat about development and get help from the community.