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 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
onRenderHtmlto write and noonRenderClient. The adapter of your UI library renders and hydrates. To change the document, use a document template (meta.document), a render handler or a server hook. - 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 ismeta.path,meta.validate,[param=matcher]orapp/routes.ts. - The server is part of the app.
server/index.tsholds handlers, middleware and plugins. A Hono, Express or Connect app mounts into it. - One config file. Vike spreads settings over
+config.jsfiles in folders. Hamur hashamur.config.ts, and_meta.tsin a folder ofapp/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.
Step by step
- Install Hamur:
bun remove vike vike-react, thenbun add hamur @hamur/adapter-react. - Write
hamur.config.tsfrom the root+config.jsandvite.config.ts(Settings). - Move each
+Pagetoapp/pages/<route>.tsx(Files and folders). - Turn each
+datainto a handler and aload(Data and guards). - Turn each
+guardinto route middleware or a request step, and each+onBeforeRouteintoapp/reroute.ts. - Move
+Head,+titleand the other head settings intoheadanduseHead(Head and document). - Move the server to
server/index.ts(The server). - Run
hamur dev, open each page, thenhamur 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 |
pages/index/+Page.tsx | app/pages/index.tsx | different | see 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 |
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 |
pages/_error/+Page.tsx | app/error.<ext> | different | the app error page, rendered without a layout; see The error page |
pages/(group)/ | app/pages/(group)/ | same | a group folder adds nothing to the path; see Pathless group layouts |
pages/+config.js | hamur.config.ts | different | see 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 |
renderer/+config.js (a renderer you wrote) | framework and @hamur/adapter-<library> | none | the adapter is the renderer. See Adapters |
vike and vike-react in package.json | hamur and @hamur/adapter-react | different | see Adapters |
vite.config.ts | hamur.config.ts | different | build is Bun.build options; a Vite plugin runs through @hamur/vite-compat; see Vite plugins |
public/ | public/ | same | see Directory structure |
dist/ | .output/ | different | see Build output |
+Page of a component library | a component | same | import it by its path. See Co-located components |
A Vike page, converted: the page and its data are two files.
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 |
+route | the file name, meta.path, meta.validate, app/routes.ts | different | see Routing |
+data | load in x.load.ts, calling a handler | different | see Data and guards |
+guard | route middleware, a request step, and a check in the handler | different | see Data and guards |
+Layout | app/layouts/<name>.<ext>, a parent page or a group layout | different | see Layouts |
+Wrapper | app/app.<ext>, the root component | different | wraps every layout and renders Outlet; see Root component |
+Loading | _pending.<ext> of the folder | different | see Pending components |
+Head | useHead in a component, head in x.load.ts, meta.head | different | see Head and document |
+title, +description, +image, +favicon, +lang, +viewport | title, seo, link, htmlAttrs and meta of a head input | different | see Head and document |
+htmlAttributes, +bodyAttributes | htmlAttrs, bodyAttrs of a head input | different | class, lang and dir on <html>; see Head |
+headHtmlBegin, +headHtmlEnd, +bodyHtmlBegin, +bodyHtmlEnd | tagPosition: "head", "bodyOpen" or "bodyClose" on a tag | different | see Position and priority |
+injectScriptsAt | tagPosition of a script | different | the entry script is written by Hamur; see 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 |
+stream | the stream route rule | different | on by default except in Vue; see The stream rule |
+prerender | the prerender route rule, entries, the static preset | different | see Prerendering |
+clientRouting | on by default | different | +clientRouting: false is an island page or a script-free page; see Island pages |
+hydrationCanBeAborted | none | none | an island hydrates on its own; see Lazy hydration |
+prefetchStaticAssets | prefetch and prefetchOn of Link, app.speculationRules | different | see Prefetch and Speculation Rules |
+keepScrollPosition | scroll of Link and navigate | different | see Scroll |
+passToClient | what a load returns, useState | different | the payload carries them; see What goes into the payload |
+redirects | routeRules with redirect, or a redirects file | different | see Redirects |
+trailingSlash, +disableUrlNormalization | app.trailingSlash, app.caseSensitive | different | see Redirects |
+baseServer | app.baseURL | same | it ends with /. See Configuration |
+baseAssets | app.cdnURL | different | an absolute URL that serves the client files. See Configuration |
+headersResponse | a headers route rule, setHeaders in a load | different | see Route rules |
+client | app/plugins/<name>.client.ts | different | see App plugins |
+server | server/index.ts | different | see The server |
+extends | framework, extends (layers) and modules | different | see Layers and Modules |
+name | name of defineModule | different | a module has a name; an app has none. See defineModule |
+meta (a setting of your own) | defineModule options, or meta keys declared with HamurPageMeta | different | see Page meta |
+cumulative | none | none | a meta key of a folder replaces the parent's, except middleware, which runs outermost first. See Page meta |
+vite | build, @hamur/vite-compat | different | see Vite plugins |
+host, +port, +https | devServer.port, devServer.https, --host | different | see Dev server |
+filesystemRoutingRoot | prefix of hamur/kit in app/routes.ts, or dir.pages | different | see A route table in code |
+onBeforeRoute | app/reroute.ts | different | see Hooks |
+onBeforePrerenderStart | entries, prerender.routes | different | see Prerendering |
+onCreatePageContext, +onCreateGlobalContext | an app plugin, a server plugin, a load | different | see Hooks |
+onRenderHtml, +onRenderClient | defineRenderHandler, server hooks | different | see Hooks |
+onPageTransitionStart, +onPageTransitionEnd | the app hooks page:start and page:finish | different | see Hooks |
+onHookCall | none | none | devServer.timing writes a performance.measure for each loader, middleware and hook under hamur dev; see 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 |
+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 |
+route as a string with an optional part | [[id]] | different | users/[[id]].tsx is /users/:id?. See 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 and 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 |
| a route with several URLs | meta.alias | different | a literal string or an array, with the page's params. See 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 |
+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 |
+onBeforeRoute that sets a locale | @hamur/i18n | different | see Internationalization |
| nested layouts by folder | a parent page that renders Outlet | different | see Nested routes |
| a modal route | an intercepting route | different | see Intercepting routes |
| parallel routes | slots | different | see 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 |
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 |
+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 |
several +Layout files that nest | nested parent pages | different | the outermost renders first. See 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 |
+Wrapper | app/app.<ext> | different | the root component around every layout. See 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 |
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.
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
},
})
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 that reads a database | a handler in server/, exported from server/index.ts | different | server/ code never reaches the browser; see Handlers |
useData() from vike-react/useData | useData() of @hamur/adapter-react | same | typed from the load; see Data in components |
pageContext.data | useData() | same | see 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 |
+data that throws redirect("/x") | redirect("/x") from hamur/app | same | return or throw it. See redirect |
+data that reads pageContext.routeParams | params of the load context | same | see Data |
+data that reads urlParsed.search | query and search of the load context | different | see 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 |
+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 |
+guard | route middleware, defineServer({ middleware }) and a check in the handler | different | see below. See Middleware |
throw render(401) in +guard | unauthorized() from hamur/app | same | it throws a 401; forbidden() is the 403. See notFound, forbidden, unauthorized |
throw redirect("/login") in +guard | redirect("/login") | same | see redirect |
throw render("/login") | rewrite("/login") from hamur/app | same | the address stays and the target renders. See rewrite |
+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 |
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 |
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 and Protecting a page and its data.
import { unauthorized } from "hamur/app"
import { defineMiddleware, getCookie } from "hamur/server"
export const admin = defineMiddleware(({ event }) => {
if (!getCookie(event, "session")) unauthorized()
})
import { defineRouteMiddleware, redirect } from "hamur/app"
export default defineRouteMiddleware((to, from, ctx) => {
if (!ctx.state.get("user")) return redirect(`/login?next=${encodeURIComponent(to.fullPath)}`)
})
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 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 |
+Head with <title>, <meta>, <link> elements | title, meta, link of a head input, or HeadTitle, HeadMeta, HeadLink | different | see Head components |
+title | title of a head input, titleTemplate | same | a titleTemplate such as %s · Shop goes in app.head. See Title template |
+description | seo.description | different | useSeoMeta and the seo key write the Open Graph and Twitter tags too; see 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 |
+favicon | app/favicon.ico or app/icon.png | different | a file in app/ becomes the link on every document; see Icons |
+lang | htmlAttrs: { lang }, or @hamur/i18n | different | see Head |
+viewport | a meta tag with name: "viewport" | different | see Head |
+htmlAttributes, +bodyAttributes | htmlAttrs, bodyAttrs | same | see 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 |
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 |
the HTML template of +onRenderHtml | app/documents/<name>.html, meta.document | different | a template with <!--hamur-head--> and <!--hamur-body-->; see Page meta |
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 and Middleware |
+guard | see Data and guards | different | |
+data | load | different | see Data |
+onBeforeRender (old) | load | different | see 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 |
+onRenderHtml that streams | the adapter streams | different | render:stream may replace the stream; see Streaming per adapter |
+onRenderClient | none | none | the adapter hydrates; the app hooks app:beforeMount and app:mounted run before and after. See 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 |
+onCreateGlobalContext | an app plugin, a server plugin | different | a server plugin runs once at start; see Server plugins and hooks |
+onPageTransitionStart | the app hook page:start, page:loading:start | different | see App hooks |
+onPageTransitionEnd | the app hook page:finish, page:loading:end | different | see App hooks |
+onBeforePrerenderStart | entries in x.load.ts, prerender.routes | different | see Prerendering |
+onHookCall | none | none | see Settings |
| a page transition animation | app.pageTransition, app.viewTransition | different | see Page and layout transitions |
A render handler wraps every page answer, the error page included:
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
}),
})
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 |
+prerender per page | meta.rules: { prerender: true } | different | see Prerendering a page without params |
+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 |
+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 |
+prerender: { partial: true } | a server preset | different | pages that are not prerendered render on each request; see Prerendered pages |
+prerender: { parallel } | prerender.workers | same | Bun workers that render from one queue; see Configuration |
vike prerender | hamur generate | same | writes .output/public/; see hamur generate |
| a crawl of the links | the prerender crawl | same | see Prerender |
+prerender that adds URLs found while rendering | paths found while rendering | same | see 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 |
a redirect with a param, /old/@id | "/old/:id": { redirect: "/new/:id" } | different | see Targets |
| an external redirect | { redirect: "https://example.com" } | same | see Targets |
| a long list of redirects | redirects: "redirects.json" | different | see The redirects file |
+trailingSlash | app.trailingSlash | different | "ignore", "redirect", "always" or "strict"; see Files and routes |
+disableUrlNormalization | app.trailingSlash: "ignore" and app.caseSensitive | different | see Files and routes |
+baseServer | app.baseURL | same | see Configuration |
+baseAssets | app.cdnURL | different | see 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 |
pageContext.urlPathname | useRoute().path | same | see 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 |
pageContext.urlParsed.search | useRoute().query | different | an object. See Search params |
pageContext.urlParsed.hash | useRoute().hash | same | see The router |
pageContext.routeParams | useRoute().params | same | see Files and routes |
pageContext.pageId | useRoute().name | different | the name comes from the file. See Files and routes |
pageContext.data | useData() | same | see Data in components |
pageContext.Page | none | none | the adapter renders the page component. See Adapters |
pageContext.config | useRuntimeConfig() | different | see Configuration |
pageContext.exports | useRoute().meta, useRoute().matched | different | matched has one { name, path, meta } for each page, outermost first. See Page meta |
pageContext.is404 | useRoute().status === 404, useError() | different | the error page and the not-found component read the error with useError(); see Errors |
pageContext.abortReason, abortStatusCode | useError(): message, data, status | different | see Errors |
pageContext.errorWhileRendering | useError() | different | see Errors |
pageContext.headers, headersOriginal | useRequestHeaders(), event.request.headers | different | see Request |
pageContext.isHydration | useRoute().navigationType === "initial" | different | see The router |
pageContext.isBackwardNavigation | useRoute().navigationType === "pop" | different | "pop" is back and forward both. See The router |
pageContext.isClientSide | import.meta.client | same | typed boolean | undefined, with import.meta.server. See Environment |
pageContext.globalContext | useApp() | different | state, hooks, config, head and what plugins provide. See App plugins |
pageContext.user and other keys added by a hook | event.context, useState | different | see State |
pageContext.userAgent | getRequestHeader(event, "user-agent") | different | see Request |
usePageContext() from vike-react | useRoute(), useData(), useApp() | different | one hook for each value. See Data in components |
Functions
| Vike | Hamur | Status | Differences |
|---|---|---|---|
render(404) | notFound() from hamur/app, or createError({ status: 404 }) | different | see notFound, forbidden, unauthorized |
render(401, "message") | unauthorized("message") | same | forbidden is 403. See notFound, forbidden, unauthorized |
render("/login") | rewrite("/login") from hamur/app | same | see rewrite |
redirect("/x") | redirect("/x") from hamur/app | same | status is the optional second argument, 302 by default; permanentRedirect is 308. See redirect |
navigate("/x") from vike/client/router | useRouter().navigate("/x"), navigateTo("/x") | different | see The router |
navigate("/x", { overwriteLastHistoryEntry: true }) | useRouter().replace("/x") | different | see The router |
navigate with keepScrollPosition | navigate(to, { scroll: false }) | different | see Scroll |
prefetch("/x") | useRouter().prefetch("/x") | same | see Prefetch |
reload() | reloadApp() of hamur/app, useRouter().refresh() | different | refresh() runs the loads again and keeps the component state. See reloadApp |
<a href> with client routing | Link from @hamur/adapter-react | different | see Links |
renderPage(pageContextInit) | the request pipeline of defineServer | none | Hamur handles the request; see 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 and 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 |
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 |
| a server route in your own server | a handler with a route | different | see A handler with a route |
| a server middleware | the middleware list of defineServer | different | see Middleware |
pageContext.user from a cookie | event.context.user, useSession | different | see Sessions and security |
| a Telefunc or tRPC call | a handler | different | a typed function the page calls; see Handlers |
| an API route for a form | <Form action={fn}> | different | works without JavaScript; see Forms and login |
| a deploy target (Vercel, Cloudflare, Node) | preset | different | see 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 |
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 |
+Page with <ClientOnly> | ClientOnly | same | see Client-only parts |
+Loading | _pending.<ext> | different | see Pending components |
an +config.js that extends another | a layer in extends | different | see Layers |
Config
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 },
},
})