# Migrating from Vike

These tables map Vike to Hamur: its files, every setting and hook of its settings and hooks pages, the `pageContext` fields and the functions it exports. The tables on pages, data and the server in [Migrating from Nuxt](/migrating-from-nuxt) apply to any app. `none` means Hamur has no equivalent today. Hamur has no `hamur migrate vike`, so the tables are the checklist.

The `Status` column says how close the Hamur way is: `same` means the name and the behavior carry over, `different` means the job has an equivalent that you write another way, and `none` means there is no equivalent; the row says what to do instead.

## The two models

Vike is a router and a renderer that you assemble: you pick a UI extension (`vike-react`, `vike-vue`, `vike-solid`), a server (`vike-server` with Hono, Express or Fastify, or your own) and the hooks that render the page. Hamur is the whole stack, so most settings that wire the pieces together are not needed:

- **Hamur renders the document.** There is no `onRenderHtml` to write and no `onRenderClient`. The adapter of your UI library renders and hydrates. To change the document, use a [document template](/api-reference/routing-details#page-meta) (`meta.document`), a [render handler](/api-reference/server#definerenderhandler-renderhandler) or a [server hook](/plugins-and-hooks#server-plugins-and-hooks).
- **Routing is by file, and in code when you need it.** `app/pages/` holds one file per route. A route function, a route string or a route table of your own is `meta.path`, `meta.validate`, `[param=matcher]` or `app/routes.ts`.
- **The server is part of the app.** `server/index.ts` holds handlers, middleware and plugins. A Hono, Express or Connect app mounts into it.
- **One config file.** Vike spreads settings over `+config.js` files in folders. Hamur has `hamur.config.ts`, and `_meta.ts` in a folder of `app/pages/` for what only that folder shares.

You pick the UI library once: `framework` in `hamur.config.ts`, installed as `@hamur/adapter-<library>`. `vike-react` becomes `@hamur/adapter-react`, `vike-vue` `@hamur/adapter-vue` and `vike-solid` `@hamur/adapter-solid`; see [Adapters](/adapters).

## Step by step

1. Install Hamur: `bun remove vike vike-react`, then `bun add hamur @hamur/adapter-react`.
2. Write `hamur.config.ts` from the root `+config.js` and `vite.config.ts` ([Settings](#settings)).
3. Move each `+Page` to `app/pages/<route>.tsx` ([Files and folders](#files-and-folders)).
4. Turn each `+data` into a handler and a `load` ([Data and guards](#data-and-guards)).
5. Turn each `+guard` into route middleware or a request step, and each `+onBeforeRoute` into `app/reroute.ts`.
6. Move `+Head`, `+title` and the other head settings into `head` and `useHead` ([Head and document](#head-and-document)).
7. Move the server to `server/index.ts` ([The server](#the-server)).
8. Run `hamur dev`, open each page, then `hamur build`.

## Files and folders

A Vike page is a folder that holds `+` files. A Hamur page is one file, and what the `+` files held goes in a file beside it or in `hamur.config.ts`.

| Vike                                         | Hamur                                      | Status    | Differences                                                                                                                                           |
| -------------------------------------------- | ------------------------------------------ | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `pages/about/+Page.tsx`                      | `app/pages/about.tsx`                      | different | one file per route, default-exporting the component; see [Files and routes](/api-reference/routing-details#files-and-routes)                          |
| `pages/index/+Page.tsx`                      | `app/pages/index.tsx`                      | different | see [Files and routes](/api-reference/routing-details#files-and-routes)                                                                               |
| `pages/product/@id/+Page.tsx`                | `app/pages/product/[id].tsx`               | different | `@id` is `[id]`; a route string `/product/@id` is the file name. See [Files and routes](/api-reference/routing-details#files-and-routes)              |
| a route string with `*` (`/docs/*`)          | `app/pages/docs/[...path].tsx`             | different | a catch-all param is a `string[]`; `[[...path]]` also matches the empty path. See [Files and routes](/api-reference/routing-details#files-and-routes) |
| `pages/_error/+Page.tsx`                     | `app/error.<ext>`                          | different | the app error page, rendered without a layout; see [The error page](/errors#the-error-page)                                                           |
| `pages/(group)/`                             | `app/pages/(group)/`                       | same      | a group folder adds nothing to the path; see [Pathless group layouts](/api-reference/routing-details#pathless-group-layouts)                          |
| `pages/+config.js`                           | `hamur.config.ts`                          | different | see [Settings](#settings)                                                                                                                             |
| `pages/admin/+config.js`                     | `app/pages/admin/_meta.ts`                 | different | run-time `meta` keys for every route in the folder and below; see [Folder config](/api-reference/routing-details#folder-config)                       |
| `renderer/+config.js` (a renderer you wrote) | `framework` and `@hamur/adapter-<library>` | none      | the adapter is the renderer. See [Adapters](/adapters)                                                                                                |
| `vike` and `vike-react` in `package.json`    | `hamur` and `@hamur/adapter-react`         | different | see [Adapters](/adapters)                                                                                                                             |
| `vite.config.ts`                             | `hamur.config.ts`                          | different | `build` is `Bun.build` options; a Vite plugin runs through `@hamur/vite-compat`; see [Vite plugins](/vite-plugins)                                    |
| `public/`                                    | `public/`                                  | same      | see [Directory structure](/directory-structure)                                                                                                       |
| `dist/`                                      | `.output/`                                 | different | see [Build output](/build-output)                                                                                                                     |
| `+Page` of a component library               | a component                                | same      | import it by its path. See [Co-located components](/api-reference/routing-details#co-located-components)                                              |

A Vike page, converted: the page and its data are two files.

````tsx [migrate-vike/app/pages/product/[id].tsx]
import { useData, useRoute } from "@hamur/adapter-react"

export default function Product() {
  const { product } = useData<{ product: { id: string; name: string } }>()
  const { params, query } = useRoute()
  return (
    <h1>
      {product.name} ({params.id}, {String(query.ref ?? "")})
    </h1>
  )
}
````

## Settings

Each setting of the Vike settings page, in the order it groups them. A setting that Vike sets in a `+config.js` is a key of `hamur.config.ts`, a `meta` key of a page or a folder, or an export of a file beside the page.

| Vike                                                                 | Hamur                                                                | Status    | Differences                                                                                                                                                |
| -------------------------------------------------------------------- | -------------------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `+Page`                                                              | the page file's default export                                       | different | see [Files and folders](#files-and-folders)                                                                                                                |
| `+route`                                                             | the file name, `meta.path`, `meta.validate`, `app/routes.ts`         | different | see [Routing](#routing)                                                                                                                                    |
| `+data`                                                              | `load` in `x.load.ts`, calling a handler                             | different | see [Data and guards](#data-and-guards)                                                                                                                    |
| `+guard`                                                             | route middleware, a request step, and a check in the handler         | different | see [Data and guards](#data-and-guards)                                                                                                                    |
| `+Layout`                                                            | `app/layouts/<name>.<ext>`, a parent page or a group layout          | different | see [Layouts](#layouts)                                                                                                                                    |
| `+Wrapper`                                                           | `app/app.<ext>`, the root component                                  | different | wraps every layout and renders `Outlet`; see [Root component](/api-reference/routing-details#root-component)                                               |
| `+Loading`                                                           | `_pending.<ext>` of the folder                                       | different | see [Pending components](/api-reference/routing-details#pending-components)                                                                                |
| `+Head`                                                              | `useHead` in a component, `head` in `x.load.ts`, `meta.head`         | different | see [Head and document](#head-and-document)                                                                                                                |
| `+title`, `+description`, `+image`, `+favicon`, `+lang`, `+viewport` | `title`, `seo`, `link`, `htmlAttrs` and `meta` of a head input       | different | see [Head and document](#head-and-document)                                                                                                                |
| `+htmlAttributes`, `+bodyAttributes`                                 | `htmlAttrs`, `bodyAttrs` of a head input                             | different | `class`, `lang` and `dir` on `<html>`; see [Head](/api-reference/head-details#attributes-of-html-and-body)                                                 |
| `+headHtmlBegin`, `+headHtmlEnd`, `+bodyHtmlBegin`, `+bodyHtmlEnd`   | `tagPosition: "head"`, `"bodyOpen"` or `"bodyClose"` on a tag        | different | see [Position and priority](/api-reference/head-details#position-and-priority)                                                                             |
| `+injectScriptsAt`                                                   | `tagPosition` of a script                                            | different | the entry script is written by Hamur; see [Position and priority](/api-reference/head-details#position-and-priority)                                       |
| `+ssr`                                                               | `meta.ssr`, or an `ssr` route rule                                   | same      | `false` makes a single-page route; `"data-only"` also exists; see [Single-page app pages](/rendering-modes#single-page-app-pages)                          |
| `+stream`                                                            | the `stream` route rule                                              | different | on by default except in Vue; see [The `stream` rule](/islands-and-streaming#the-stream-rule)                                                               |
| `+prerender`                                                         | the `prerender` route rule, `entries`, the `static` preset           | different | see [Prerendering](#prerendering)                                                                                                                          |
| `+clientRouting`                                                     | on by default                                                        | different | `+clientRouting: false` is an island page or a script-free page; see [Island pages](/rendering-modes#island-pages)                                         |
| `+hydrationCanBeAborted`                                             | none                                                                 | none      | an island hydrates on its own; see [Lazy hydration](/islands-and-streaming#lazy-hydration)                                                                 |
| `+prefetchStaticAssets`                                              | `prefetch` and `prefetchOn` of `Link`, `app.speculationRules`        | different | see [Prefetch](/api-reference/navigation-details#prefetch) and [Speculation Rules](/api-reference/navigation-details#speculation-rules)                    |
| `+keepScrollPosition`                                                | `scroll` of `Link` and `navigate`                                    | different | see [Scroll](/api-reference/navigation-details#scroll)                                                                                                     |
| `+passToClient`                                                      | what a `load` returns, `useState`                                    | different | the payload carries them; see [What goes into the payload](/data#what-goes-into-the-payload)                                                               |
| `+redirects`                                                         | `routeRules` with `redirect`, or a redirects file                    | different | see [Redirects](#redirects-and-urls)                                                                                                                       |
| `+trailingSlash`, `+disableUrlNormalization`                         | `app.trailingSlash`, `app.caseSensitive`                             | different | see [Redirects](#redirects-and-urls)                                                                                                                       |
| `+baseServer`                                                        | `app.baseURL`                                                        | same      | it ends with `/`. See [Configuration](/configuration)                                                                                                      |
| `+baseAssets`                                                        | `app.cdnURL`                                                         | different | an absolute URL that serves the client files. See [Configuration](/configuration)                                                                          |
| `+headersResponse`                                                   | a `headers` route rule, `setHeaders` in a `load`                     | different | see [Route rules](/route-rules#keys)                                                                                                                       |
| `+client`                                                            | `app/plugins/<name>.client.ts`                                       | different | see [App plugins](/plugins-and-hooks#app-plugins)                                                                                                          |
| `+server`                                                            | `server/index.ts`                                                    | different | see [The server](#the-server)                                                                                                                              |
| `+extends`                                                           | `framework`, `extends` (layers) and `modules`                        | different | see [Layers](/layers) and [Modules](/modules)                                                                                                              |
| `+name`                                                              | `name` of `defineModule`                                             | different | a module has a name; an app has none. See [`defineModule`](/modules#the-fields-of-definemodule)                                                            |
| `+meta` (a setting of your own)                                      | `defineModule` options, or `meta` keys declared with `HamurPageMeta` | different | see [Page meta](/api-reference/routing-details#page-meta)                                                                                                  |
| `+cumulative`                                                        | none                                                                 | none      | a `meta` key of a folder replaces the parent's, except `middleware`, which runs outermost first. See [Page meta](/api-reference/routing-details#page-meta) |
| `+vite`                                                              | `build`, `@hamur/vite-compat`                                        | different | see [Vite plugins](/vite-plugins)                                                                                                                          |
| `+host`, `+port`, `+https`                                           | `devServer.port`, `devServer.https`, `--host`                        | different | see [Dev server](/dev-server)                                                                                                                              |
| `+filesystemRoutingRoot`                                             | `prefix` of `hamur/kit` in `app/routes.ts`, or `dir.pages`           | different | see [A route table in code](/api-reference/routing-details#a-route-table-in-code)                                                                          |
| `+onBeforeRoute`                                                     | `app/reroute.ts`                                                     | different | see [Hooks](#hooks)                                                                                                                                        |
| `+onBeforePrerenderStart`                                            | `entries`, `prerender.routes`                                        | different | see [Prerendering](#prerendering)                                                                                                                          |
| `+onCreatePageContext`, `+onCreateGlobalContext`                     | an app plugin, a server plugin, a `load`                             | different | see [Hooks](#hooks)                                                                                                                                        |
| `+onRenderHtml`, `+onRenderClient`                                   | `defineRenderHandler`, server hooks                                  | different | see [Hooks](#hooks)                                                                                                                                        |
| `+onPageTransitionStart`, `+onPageTransitionEnd`                     | the app hooks `page:start` and `page:finish`                         | different | see [Hooks](#hooks)                                                                                                                                        |
| `+onHookCall`                                                        | none                                                                 | none      | `devServer.timing` writes a `performance.measure` for each loader, middleware and hook under `hamur dev`; see [Configuration](/configuration)              |

## Routing

Vike routes by the file system, a route string or a route function, and one page can use any of them. Hamur routes by the file system and lets you change the result in code.

| Vike                                                         | Hamur                                                                  | Status    | Differences                                                                                                                                                                                                                               |
| ------------------------------------------------------------ | ---------------------------------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| filesystem routing                                           | `app/pages/**`                                                         | same      | see [Files and routes](/api-reference/routing-details#files-and-routes)                                                                                                                                                                   |
| `+route` as a string, `/product/@id`                         | `app/pages/product/[id].tsx`, or `meta.path: "/product/:id"`           | different | `meta.path` replaces the path the file gives and is a literal string the build reads; see [Build keys must be literals](/api-reference/routing-details#build-keys-must-be-literals)                                                       |
| `+route` as a string with an optional part                   | `[[id]]`                                                               | different | `users/[[id]].tsx` is `/users/:id?`. See [Files and routes](/api-reference/routing-details#files-and-routes)                                                                                                                              |
| `+route` as a function, returning `{ routeParams }`          | `[id=integer]` with `app/params/integer.ts`, or `meta.validate(route)` | different | a matcher takes the value or goes on to the next route; `validate` answers 404; see [Param matchers](/api-reference/routing-details#param-matchers) and [Params that are checked](/api-reference/routing-details#params-that-are-checked) |
| `+route` as a function that reads `urlPathname`              | `app/routes.ts`                                                        | different | one function over the scanned records; see [A route table in code](/api-reference/routing-details#a-route-table-in-code)                                                                                                                  |
| a route with several URLs                                    | `meta.alias`                                                           | different | a literal string or an array, with the page's params. See [Page meta](/api-reference/routing-details#page-meta)                                                                                                                           |
| `precedence` of a route                                      | the order Hamur gives                                                  | none      | the best match wins, segment by segment: static, mixed, required param, optional param, catch-all. See [Files and routes](/api-reference/routing-details#files-and-routes)                                                                |
| `+onBeforeRoute` returning `{ pageContext: { urlLogical } }` | `input(url)` of `app/reroute.ts`                                       | different | a URL maps to an app path on the server and in the browser; `useRoute().mask` is the address bar's path; see [Rewrites](/route-rules#rewrites)                                                                                            |
| `+onBeforeRoute` that sets a locale                          | `@hamur/i18n`                                                          | different | see [Internationalization](/i18n)                                                                                                                                                                                                         |
| nested layouts by folder                                     | a parent page that renders `Outlet`                                    | different | see [Nested routes](/api-reference/routing-details#nested-routes)                                                                                                                                                                         |
| a modal route                                                | an intercepting route                                                  | different | see [Intercepting routes](/api-reference/routing-details#intercepting-routes)                                                                                                                                                             |
| parallel routes                                              | slots                                                                  | different | see [Slots](/api-reference/routing-details#slots)                                                                                                                                                                                         |
| `+route` that uses `pageContext.data`                        | none                                                                   | none      | a route is decided before any `load` runs; check the data in the `load` or in `meta.validate`. See [Params that are checked](/api-reference/routing-details#params-that-are-checked)                                                      |

````ts [routing/routes.ts]
import { group, index, prefix, route, type RouteRecord } from "hamur/kit"

export default (scanned: RouteRecord[]): RouteRecord[] => [
  ...scanned,
  index("screens/home.tsx"),
  route("legal", "screens/legal.tsx", [route("terms", "screens/terms.tsx")]),
  group("screens/(shell).tsx", [route("settings", "screens/settings.tsx")]),
  ...prefix("/v2", [route("about", "screens/about.tsx")]),
]
````

## Layouts

| Vike                                   | Hamur                                                        | Status    | Differences                                                                                                                                                                         |
| -------------------------------------- | ------------------------------------------------------------ | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `+Layout` in `pages/+Layout.tsx`       | `app/layouts/default.<ext>`                                  | different | a layout renders `children`; `default` wraps every page. See [Layouts](/api-reference/routing-details#layouts)                                                                      |
| `+Layout` in a folder                  | a parent page, or a `(group).tsx` beside a `(group)/` folder | different | a folder's layout is its parent page, which renders `Outlet`; a group adds nothing to the path; see [Pathless group layouts](/api-reference/routing-details#pathless-group-layouts) |
| several `+Layout` files that nest      | nested parent pages                                          | different | the outermost renders first. See [Nested routes](/api-reference/routing-details#nested-routes)                                                                                      |
| a layout that reads `pageContext.data` | a layout's `load` in `app/layouts/<name>.load.ts`            | different | read with `useData()` in the layout; see [Layout loads](/data#layout-loads)                                                                                                         |
| `+Wrapper`                             | `app/app.<ext>`                                              | different | the root component around every layout. See [Root component](/api-reference/routing-details#root-component)                                                                         |
| a layout with persistent state         | a layout or parent page that stays mounted                   | same      | a navigation keeps the layout's state. See [Layouts](/api-reference/routing-details#layouts)                                                                                        |

## Data and guards

A page reads its data in a `load` of `x.load.ts` beside it, which calls a handler. The handler runs only on the server and is a public endpoint, so it checks its input. See [Data](/data).

````ts [migrate-vike/server/product.ts]
import { createError, defineHandler } from "hamur/server"
import { schema } from "../../migrate-next/server/schema.ts"

const products = new Map([["1", { id: "1", name: "Lamp" }]])

const idInput = schema<{ id: string }>(
  { type: "object", properties: { id: { type: "string" } }, required: ["id"] },
  (value) => {
    const id = (value as { id?: unknown } | undefined)?.id
    return typeof id === "string" && id
      ? { value: { id } }
      : { issues: [{ message: "An id is required", path: ["id"] }] }
  },
)

export const listProducts = defineHandler({
  method: "GET",
  handler: () => [...products.values()],
})

export const getProduct = defineHandler({
  method: "GET",
  input: idInput,
  handler({ id }) {
    const product = products.get(id)
    if (!product) throw createError({ status: 404, message: "Product not found" })
    return product
  },
})
````

````ts [migrate-vike/app/pages/product/[id].load.ts]
import type { Entries, Load } from "hamur/app"
import { getProduct, listProducts } from "../../../server/index.ts"

export const entries = (async () => (await listProducts()).map(({ id }) => ({ id }))) satisfies Entries
export const dynamicParams = false

export const load = (async ({ params }) => ({ product: await getProduct({ id: params.id as string }) })) satisfies Load
````

| Vike                                          | Hamur                                                                       | Status    | Differences                                                                                                                                                             |
| --------------------------------------------- | --------------------------------------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `+data`                                       | `load` in `x.load.ts`                                                       | different | it runs on the server for the first render and in the browser for each navigation; it holds no server code of its own, it calls handlers. See [Data](/data)             |
| `+data` that reads a database                 | a handler in `server/`, exported from `server/index.ts`                     | different | `server/` code never reaches the browser; see [Handlers](/handlers#defining-a-handler)                                                                                  |
| `useData()` from `vike-react/useData`         | `useData()` of `@hamur/adapter-react`                                       | same      | typed from the `load`; see [Data in components](/adapters#data-in-components)                                                                                           |
| `pageContext.data`                            | `useData()`                                                                 | same      | see [Data in components](/adapters#data-in-components)                                                                                                                  |
| `+data` that throws `render(404)`             | `notFound()` from `hamur/app`                                               | different | it throws `createError({ status: 404 })`; the not-found component of the route shows it; see [Route boundaries](/errors#route-boundaries)                               |
| `+data` that throws `redirect("/x")`          | `redirect("/x")` from `hamur/app`                                           | same      | return or throw it. See [`redirect`](/api-reference/app#redirect-isredirect-hamurredirect)                                                                              |
| `+data` that reads `pageContext.routeParams`  | `params` of the `load` context                                              | same      | see [Data](/data)                                                                                                                                                       |
| `+data` that reads `urlParsed.search`         | `query` and `search` of the `load` context                                  | different | see [Search params](/api-reference/routing-details#search-params)                                                                                                       |
| `+data` that reads `pageContext.headers`      | `event.request.headers` of the handler                                      | different | `event` is `undefined` in the browser; `useRequestHeaders()` in a component. See [Request](/api-reference/app#request)                                                  |
| `+data` on a client navigation                | the `load` runs in the browser and calls the handler                        | different | the call is a request to `/_hamur/fn/<id>`; see [Calling a handler](/handlers#calling-a-handler)                                                                        |
| `+guard`                                      | route middleware, `defineServer({ middleware })` and a check in the handler | different | see below. See [Middleware](/api-reference/routing-details#route-middleware)                                                                                            |
| `throw render(401)` in `+guard`               | `unauthorized()` from `hamur/app`                                           | same      | it throws a 401; `forbidden()` is the 403. See [`notFound`, `forbidden`, `unauthorized`](/api-reference/app#notfound-forbidden-unauthorized)                            |
| `throw redirect("/login")` in `+guard`        | `redirect("/login")`                                                        | same      | see [`redirect`](/api-reference/app#redirect-isredirect-hamurredirect)                                                                                                  |
| `throw render("/login")`                      | `rewrite("/login")` from `hamur/app`                                        | same      | the address stays and the target renders. See [`rewrite`](/api-reference/app#rewrite-isrewrite-hamurrewrite)                                                            |
| `+guard` that runs on the client              | `defineRouteMiddleware` from `hamur/app`                                    | different | it runs on the server for the document and in the browser for a navigation, and guards no data. See [`defineRouteMiddleware`](/api-reference/app#defineroutemiddleware) |
| `pageContext.user` set by a server middleware | `event.context.user`                                                        | different | a request step writes it, a handler and a `load` read it. See [Middleware](/server#middleware)                                                                          |

A guard has three places, and a page that matters has two. A request step guards the document under a path. The handler's check guards the data on every call, from the page or from outside. A route middleware only makes a navigation in the browser quick; it never guards data. See [A `load` does not guard anything](/data#a-load-does-not-guard-anything) and [Protecting a page and its data](/sessions-and-security#protecting-a-page-and-its-data).

````ts [migrate-vike/server/guard.ts]
import { unauthorized } from "hamur/app"
import { defineMiddleware, getCookie } from "hamur/server"

export const admin = defineMiddleware(({ event }) => {
  if (!getCookie(event, "session")) unauthorized()
})
````

````ts [auth-middleware.ts]
import { defineRouteMiddleware, redirect } from "hamur/app"

export default defineRouteMiddleware((to, from, ctx) => {
  if (!ctx.state.get("user")) return redirect(`/login?next=${encodeURIComponent(to.fullPath)}`)
})
````

````ts [routing/admin/_meta.ts]
import type { PageMeta } from "hamur/app"
import auth from "../../middleware/auth.ts"

export const meta = { middleware: [auth], layout: "admin" } satisfies PageMeta
````

## Head and document

| Vike                                                | Hamur                                                                           | Status    | Differences                                                                                                                                                |
| --------------------------------------------------- | ------------------------------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `+Head`                                             | `useHead(input)` from `@hamur/adapter-react`                                    | different | a hook the component calls, not a component; see [Head](/head)                                                                                             |
| `+Head` that reads `pageContext.data`               | a `head` export of `x.load.ts`                                                  | different | it receives the load context and the data; see [Head from the route](/api-reference/head-details#head-from-the-route)                                      |
| `+Head` with `<title>`, `<meta>`, `<link>` elements | `title`, `meta`, `link` of a head input, or `HeadTitle`, `HeadMeta`, `HeadLink` | different | see [Head components](/api-reference/head-details#head-components)                                                                                         |
| `+title`                                            | `title` of a head input, `titleTemplate`                                        | same      | a `titleTemplate` such as `%s · Shop` goes in `app.head`. See [Title template](/api-reference/head-details#title-template)                                 |
| `+description`                                      | `seo.description`                                                               | different | `useSeoMeta` and the `seo` key write the Open Graph and Twitter tags too; see [Search and social tags](/api-reference/head-details#search-and-social-tags) |
| `+image`                                            | `useSeoMeta({ ogImage })`, or an `opengraph-image.png` file in `app/`           | different | a generated image comes from `@hamur/og-image`; see [Open Graph and Twitter images](/api-reference/head-details#open-graph-and-twitter-images)             |
| `+favicon`                                          | `app/favicon.ico` or `app/icon.png`                                             | different | a file in `app/` becomes the link on every document; see [Icons](/api-reference/head-details#icons)                                                        |
| `+lang`                                             | `htmlAttrs: { lang }`, or `@hamur/i18n`                                         | different | see [Head](/head)                                                                                                                                          |
| `+viewport`                                         | a `meta` tag with `name: "viewport"`                                            | different | see [Head](/head)                                                                                                                                          |
| `+htmlAttributes`, `+bodyAttributes`                | `htmlAttrs`, `bodyAttrs`                                                        | same      | see [Attributes of `<html>` and `<body>`](/api-reference/head-details#attributes-of-html-and-body)                                                         |
| a head tag only for some pages                      | `meta.head` of a page, `head` of its load                                       | different | see [Head from the route](/api-reference/head-details#head-from-the-route)                                                                                 |
| a `+Head` of a layout                               | `useHead` in the layout                                                         | same      | a component's `useHead` wins over the route's for the same key. See [Head](/head)                                                                          |
| the HTML template of `+onRenderHtml`                | `app/documents/<name>.html`, `meta.document`                                    | different | a template with `<!--hamur-head-->` and `<!--hamur-body-->`; see [Page meta](/api-reference/routing-details#page-meta)                                     |

````ts [seo/blog-post.load.ts]
import type { Load, LoadHead } from "hamur/app"

interface Post {
  title: string
  summary: string
  slug: string
}

async function getPost(slug: string): Promise<Post> {
  return { title: "Hello", summary: "First post", slug }
}

export const load = (async ({ params }) => ({ post: await getPost(params.slug as string) })) satisfies Load

export const head = (({ data }) => ({
  title: data.post.title,
  seo: { description: data.post.summary, ogType: "article" },
  jsonLd: {
    "@type": "BlogPosting",
    "@id": `https://example.com/blog/${data.post.slug}#article`,
    headline: data.post.title,
  },
})) satisfies LoadHead<typeof load>
````

## Hooks

Hamur has no hook that renders; the hooks that remain are for plugins and for the cases that wrap a render.

| Vike                         | Hamur                                                                                                              | Status    | Differences                                                                                                                                                                                   |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------ | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `+onBeforeRoute`             | `input(url)` of `app/reroute.ts`, or a request step that returns `rewrite(path)`                                   | different | `input` also runs in the browser before each navigation; see [Rewrites](/route-rules#rewrites) and [Middleware](/server#middleware)                                                           |
| `+guard`                     | see [Data and guards](#data-and-guards)                                                                            | different |                                                                                                                                                                                               |
| `+data`                      | `load`                                                                                                             | different | see [Data](/data)                                                                                                                                                                             |
| `+onBeforeRender` (old)      | `load`                                                                                                             | different | see [Data](/data)                                                                                                                                                                             |
| `+onRenderHtml`              | `defineRenderHandler` of `hamur/server`, and the server hooks `render:html`, `render:stream` and `render:response` | different | the handler wraps the answer; `render:html` gets the parts of the document; see [Change the error answer and the page answer](/plugins-and-hooks#change-the-error-answer-and-the-page-answer) |
| `+onRenderHtml` that streams | the adapter streams                                                                                                | different | `render:stream` may replace the stream; see [Streaming per adapter](/islands-and-streaming#streaming-per-adapter)                                                                             |
| `+onRenderClient`            | none                                                                                                               | none      | the adapter hydrates; the app hooks `app:beforeMount` and `app:mounted` run before and after. See [App hooks](/plugins-and-hooks#app-hooks)                                                   |
| `+onCreatePageContext`       | an app plugin, or a `load`                                                                                         | different | a plugin runs once for each app (one for each request on the server); see [App plugins](/plugins-and-hooks#app-plugins)                                                                       |
| `+onCreateGlobalContext`     | an app plugin, a server plugin                                                                                     | different | a server plugin runs once at start; see [Server plugins and hooks](/plugins-and-hooks#server-plugins-and-hooks)                                                                               |
| `+onPageTransitionStart`     | the app hook `page:start`, `page:loading:start`                                                                    | different | see [App hooks](/plugins-and-hooks#app-hooks)                                                                                                                                                 |
| `+onPageTransitionEnd`       | the app hook `page:finish`, `page:loading:end`                                                                     | different | see [App hooks](/plugins-and-hooks#app-hooks)                                                                                                                                                 |
| `+onBeforePrerenderStart`    | `entries` in `x.load.ts`, `prerender.routes`                                                                       | different | see [Prerendering](#prerendering)                                                                                                                                                             |
| `+onHookCall`                | none                                                                                                               | none      | see [Settings](#settings)                                                                                                                                                                     |
| a page transition animation  | `app.pageTransition`, `app.viewTransition`                                                                         | different | see [Page and layout transitions](/api-reference/navigation-details#page-and-layout-transitions)                                                                                              |

A render handler wraps every page answer, the error page included:

````ts [migrate-vike/server/index.ts]
import { defineRenderHandler, defineServer } from "hamur/server"
import { admin } from "./guard.ts"

export { getProduct, listProducts } from "./product.ts"

export default defineServer({
  middleware: [{ route: "/admin/**", handler: admin }],
  render: defineRenderHandler(async (_event, { render }) => {
    const response = await render()
    response.headers.set("x-rendered-by", "hamur")
    return response
  }),
})
````

````ts [rules/app/reroute.ts]
const slugs: Record<string, string> = { "/de/ueber-uns": "/about", "/fr/a-propos": "/about" }

export function input(url: URL): string | undefined {
  return slugs[url.pathname]
}

export function output(url: URL): string | undefined {
  const match = /^\/tenants\/[^/]+(\/.*)$/.exec(url.pathname)
  if (match) return match[1] + url.search
}
````

## Prerendering

| Vike                                                        | Hamur                                                | Status    | Differences                                                                                                                                                         |
| ----------------------------------------------------------- | ---------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `+prerender: true`                                          | `preset: "static"`, or `prerender: true` route rules | different | `static` prerenders every route; on a server preset a rule names the paths; see [Route rules and prerender](/route-rules#prerender)                                 |
| `+prerender` per page                                       | `meta.rules: { prerender: true }`                    | different | see [Prerendering a page without params](/data#prerender-a-page)                                                                                                    |
| `+onBeforePrerenderStart` returning URLs                    | `entries` in `x.load.ts`                             | different | one object of params per path; `dynamicParams = false` makes them the only paths; see [Pages to prerender](/data#pages-to-prerender-with-entries-and-dynamicparams) |
| `+onBeforePrerenderStart` returning URLs with `pageContext` | `entries`, and a `load` that reads the data          | different | the prerender shares the answers of one run. See [Pages to prerender](/data#pages-to-prerender-with-entries-and-dynamicparams)                                      |
| `+prerender: { partial: true }`                             | a server preset                                      | different | pages that are not prerendered render on each request; see [Prerendered pages](/rendering-modes#prerendered-pages)                                                  |
| `+prerender: { parallel }`                                  | `prerender.workers`                                  | same      | Bun workers that render from one queue; see [Configuration](/configuration)                                                                                         |
| `vike prerender`                                            | `hamur generate`                                     | same      | writes `.output/public/`; see [`hamur generate`](/cli#hamur-generate)                                                                                               |
| a crawl of the links                                        | the prerender crawl                                  | same      | see [Prerender](/route-rules#prerender)                                                                                                                             |
| `+prerender` that adds URLs found while rendering           | paths found while rendering                          | same      | see [Paths found while rendering](/route-rules#paths-found-while-rendering)                                                                                         |

## Redirects and URLs

| Vike                                | Hamur                                                 | Status    | Differences                                                                                                                 |
| ----------------------------------- | ----------------------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------- |
| `+redirects: { "/old": "/new" }`    | `routeRules["/old"] = { redirect: "/new" }`           | different | 307 unless you give a status; see [Redirect status](/route-rules#redirect-status)                                           |
| a redirect with a param, `/old/@id` | `"/old/:id": { redirect: "/new/:id" }`                | different | see [Targets](/route-rules#targets)                                                                                         |
| an external redirect                | `{ redirect: "https://example.com" }`                 | same      | see [Targets](/route-rules#targets)                                                                                         |
| a long list of redirects            | `redirects: "redirects.json"`                         | different | see [The redirects file](/route-rules#the-redirects-file)                                                                   |
| `+trailingSlash`                    | `app.trailingSlash`                                   | different | `"ignore"`, `"redirect"`, `"always"` or `"strict"`; see [Files and routes](/api-reference/routing-details#files-and-routes) |
| `+disableUrlNormalization`          | `app.trailingSlash: "ignore"` and `app.caseSensitive` | different | see [Files and routes](/api-reference/routing-details#files-and-routes)                                                     |
| `+baseServer`                       | `app.baseURL`                                         | same      | see [Configuration](/configuration)                                                                                         |
| `+baseAssets`                       | `app.cdnURL`                                          | different | see [Configuration](/configuration)                                                                                         |

## `pageContext`

Hamur has no object that holds the request, the route and the data. Each value has its own place, and none of them is global state.

| Vike                                              | Hamur                                                       | Status    | Differences                                                                                                                        |
| ------------------------------------------------- | ----------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `pageContext.urlOriginal`                         | `useRoute().fullPath`, `getRequestURL(event)` on the server | different | `fullPath` is without `app.baseURL`. See [The router](/api-reference/navigation-details#the-router)                                |
| `pageContext.urlPathname`                         | `useRoute().path`                                           | same      | see [The router](/api-reference/navigation-details#the-router)                                                                     |
| `pageContext.urlLogical`                          | `useRoute().path`                                           | same      | with `app/reroute.ts` the path is the target's and `useRoute().mask` the address bar's. See [Rewrites](/route-rules#rewrites)      |
| `pageContext.urlParsed.search`                    | `useRoute().query`                                          | different | an object. See [Search params](/api-reference/routing-details#search-params)                                                       |
| `pageContext.urlParsed.hash`                      | `useRoute().hash`                                           | same      | see [The router](/api-reference/navigation-details#the-router)                                                                     |
| `pageContext.routeParams`                         | `useRoute().params`                                         | same      | see [Files and routes](/api-reference/routing-details#files-and-routes)                                                            |
| `pageContext.pageId`                              | `useRoute().name`                                           | different | the name comes from the file. See [Files and routes](/api-reference/routing-details#files-and-routes)                              |
| `pageContext.data`                                | `useData()`                                                 | same      | see [Data in components](/adapters#data-in-components)                                                                             |
| `pageContext.Page`                                | none                                                        | none      | the adapter renders the page component. See [Adapters](/adapters)                                                                  |
| `pageContext.config`                              | `useRuntimeConfig()`                                        | different | see [Configuration](/configuration)                                                                                                |
| `pageContext.exports`                             | `useRoute().meta`, `useRoute().matched`                     | different | `matched` has one `{ name, path, meta }` for each page, outermost first. See [Page meta](/api-reference/routing-details#page-meta) |
| `pageContext.is404`                               | `useRoute().status === 404`, `useError()`                   | different | the error page and the not-found component read the error with `useError()`; see [Errors](/errors)                                 |
| `pageContext.abortReason`, `abortStatusCode`      | `useError()`: `message`, `data`, `status`                   | different | see [Errors](/errors)                                                                                                              |
| `pageContext.errorWhileRendering`                 | `useError()`                                                | different | see [Errors](/errors)                                                                                                              |
| `pageContext.headers`, `headersOriginal`          | `useRequestHeaders()`, `event.request.headers`              | different | see [Request](/api-reference/app#request)                                                                                          |
| `pageContext.isHydration`                         | `useRoute().navigationType === "initial"`                   | different | see [The router](/api-reference/navigation-details#the-router)                                                                     |
| `pageContext.isBackwardNavigation`                | `useRoute().navigationType === "pop"`                       | different | `"pop"` is back and forward both. See [The router](/api-reference/navigation-details#the-router)                                   |
| `pageContext.isClientSide`                        | `import.meta.client`                                        | same      | typed `boolean \| undefined`, with `import.meta.server`. See [Environment](/environment#importmetaenv-and-importmetaprerender)     |
| `pageContext.globalContext`                       | `useApp()`                                                  | different | `state`, `hooks`, `config`, `head` and what plugins `provide`. See [App plugins](/plugins-and-hooks#app-plugins)                   |
| `pageContext.user` and other keys added by a hook | `event.context`, `useState`                                 | different | see [State](/state)                                                                                                                |
| `pageContext.userAgent`                           | `getRequestHeader(event, "user-agent")`                     | different | see [Request](/api-reference/server#getrequestip-getrequesturl)                                                                    |
| `usePageContext()` from `vike-react`              | `useRoute()`, `useData()`, `useApp()`                       | different | one hook for each value. See [Data in components](/adapters#data-in-components)                                                    |

## Functions

| Vike                                                       | Hamur                                                            | Status    | Differences                                                                                                                                                 |
| ---------------------------------------------------------- | ---------------------------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `render(404)`                                              | `notFound()` from `hamur/app`, or `createError({ status: 404 })` | different | see [`notFound`, `forbidden`, `unauthorized`](/api-reference/app#notfound-forbidden-unauthorized)                                                           |
| `render(401, "message")`                                   | `unauthorized("message")`                                        | same      | `forbidden` is 403. See [`notFound`, `forbidden`, `unauthorized`](/api-reference/app#notfound-forbidden-unauthorized)                                       |
| `render("/login")`                                         | `rewrite("/login")` from `hamur/app`                             | same      | see [`rewrite`](/api-reference/app#rewrite-isrewrite-hamurrewrite)                                                                                          |
| `redirect("/x")`                                           | `redirect("/x")` from `hamur/app`                                | same      | status is the optional second argument, 302 by default; `permanentRedirect` is 308. See [`redirect`](/api-reference/app#redirect-isredirect-hamurredirect)  |
| `navigate("/x")` from `vike/client/router`                 | `useRouter().navigate("/x")`, `navigateTo("/x")`                 | different | see [The router](/api-reference/navigation-details#the-router)                                                                                              |
| `navigate("/x", { overwriteLastHistoryEntry: true })`      | `useRouter().replace("/x")`                                      | different | see [The router](/api-reference/navigation-details#the-router)                                                                                              |
| `navigate` with `keepScrollPosition`                       | `navigate(to, { scroll: false })`                                | different | see [Scroll](/api-reference/navigation-details#scroll)                                                                                                      |
| `prefetch("/x")`                                           | `useRouter().prefetch("/x")`                                     | same      | see [Prefetch](/api-reference/navigation-details#prefetch)                                                                                                  |
| `reload()`                                                 | `reloadApp()` of `hamur/app`, `useRouter().refresh()`            | different | `refresh()` runs the loads again and keeps the component state. See [`reloadApp`](/api-reference/app#reloadapp-reloadappoptions)                            |
| `<a href>` with client routing                             | `Link` from `@hamur/adapter-react`                               | different | see [Links](/api-reference/navigation-details#links)                                                                                                        |
| `renderPage(pageContextInit)`                              | the request pipeline of `defineServer`                           | none      | Hamur handles the request; see [Order of a request](/api-reference/server-details#order-of-a-request)                                                       |
| `vike/server` `renderPage` with Hono, Express or Fastify   | a mounted fetch app, or an Express or Connect handler            | different | see [Mount a fetch app](/server#mount-a-fetch-app) and [Run an Express or Connect handler](/api-reference/server-details#run-an-express-or-connect-handler) |
| `vike prerender`, `vike build`, `vike dev`, `vike preview` | `hamur generate`, `hamur build`, `hamur dev`, `hamur preview`    | same      | see [CLI](/cli)                                                                                                                                             |

## The server

| Vike                                              | Hamur                                   | Status    | Differences                                                                                                                        |
| ------------------------------------------------- | --------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `vike-server` with a Hono, Express or Fastify app | `server/index.ts` with `defineServer`   | different | handlers, middleware and plugins are Hamur's; a fetch app or an Express handler mounts into it. See [Server](/server#the-one-door) |
| a server route in your own server                 | a handler with a `route`                | different | see [A handler with a route](/server#a-handler-with-a-route)                                                                       |
| a server middleware                               | the `middleware` list of `defineServer` | different | see [Middleware](/server#middleware)                                                                                               |
| `pageContext.user` from a cookie                  | `event.context.user`, `useSession`      | different | see [Sessions and security](/sessions-and-security)                                                                                |
| a Telefunc or tRPC call                           | a handler                               | different | a typed function the page calls; see [Handlers](/handlers)                                                                         |
| an API route for a form                           | `<Form action={fn}>`                    | different | works without JavaScript; see [Forms and login](/forms-and-login)                                                                  |
| a deploy target (Vercel, Cloudflare, Node)        | `preset`                                | different | see [Presets](/deploy#presets)                                                                                                     |

## Extensions

| Vike                                                           | Hamur                                                                | Status    | Differences                                                                                                      |
| -------------------------------------------------------------- | -------------------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------- |
| `vike-react`, `vike-vue`, `vike-solid`                         | `@hamur/adapter-react`, `@hamur/adapter-vue`, `@hamur/adapter-solid` | same      | `@hamur/adapter-preact`, `@hamur/adapter-svelte` and `@hamur/adapter-html` also exist; see [Adapters](/adapters) |
| a state library of `vike-react` (a Zustand or Redux extension) | the library's own package                                            | none      | install it as a dependency; the state of Hamur is `useState`, see [State](/state)                                |
| `+Page` with `<ClientOnly>`                                    | `ClientOnly`                                                         | same      | see [Client-only parts](/islands-and-streaming#client-only-parts-and-hydration-helpers)                          |
| `+Loading`                                                     | `_pending.<ext>`                                                     | different | see [Pending components](/api-reference/routing-details#pending-components)                                      |
| an `+config.js` that extends another                           | a layer in `extends`                                                 | different | see [Layers](/layers)                                                                                            |

## Config

````ts [migrate-vike/hamur.config.ts]
import { defineConfig } from "hamur"

export default defineConfig({
  framework: "react",
  preset: "node",
  app: { baseURL: "/shop/", trailingSlash: "redirect", head: { titleTemplate: "%s · Shop" } },
  routeRules: {
    "/old/:id": { redirect: { to: "/product/:id", status: 301 } },
    "/product/**": { prerender: true },
    "/account/**": { ssr: false },
  },
})
````
