Migrating from Astro
These tables map Astro to Hamur: its files, its .astro syntax, its client:* directives, the Astro global, its astro:* modules, actions, content collections, middleware, endpoints, integrations and adapters. The tables on pages, data and the server in Migrating from Nuxt apply to any app. hamur migrate astro reads your app and writes hamur-migration.md, the same tables filtered to what the app uses; with --write it turns each endpoint of src/pages/ into a handler. It never rewrites an .astro file, so the tables are also the checklist for those.
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 Hamur has no equivalent today; the row says what to do instead.
The two models
Astro renders pages to HTML and ships no JavaScript unless a component asks for it with a client:* directive. Hamur renders a page on the server and hydrates the whole page in the browser, the way a Nuxt or Next app does. An Astro app is therefore moved in one of two ways:
- Keep the islands. A page with
meta.hydrate: "islands"ships no app entry; only the components you render throughIslandhydrate. This is the nearest to Astro, and it needsexperimental.islands: true. See Island pages. - Hydrate the page. A page that is mostly interactive is an ordinary page, and its navigations stay in the browser.
Astro takes components of several UI libraries in one app. A Hamur app has one library. It is react, preact, vue, solid, svelte or html, set by framework in hamur.config.ts and installed as @hamur/adapter-<library>. An html app may host islands of other libraries; see html islands and second-library islands.
Step by step
- Run
hamur migrate astroin the app. It changes nothing and writeshamur-migration.md: each Astro name the app uses, its Hamur equivalent, the file and line, and whether--writecan rewrite it. - Run
hamur migrate astro --write. It turns each exported method of an endpoint insrc/pages/(GET,POST, …) into a raw handler ofserver/routes/, exported fromserver/index.ts. The original file stays. An endpoint is rewritten only when it readsparams,urlandrequestof its context and uses no name ofastro; any other endpoint is left with its reason in the report. Pages, layouts, components, content collections, middleware and actions are reported and never moved. - Install Hamur:
bun remove astro, thenbun add hamur @hamur/adapter-react. Pick the adapter of the library most of your components use. - Write
hamur.config.tsfromastro.config.*(config keys). - Move
src/pagestoapp/pages,src/layoutstoapp/layoutsandsrc/componentstoapp/components, then turn each.astrofile into a component of your library (Files and folders). - Move what the frontmatter of a page fetches into a handler and a
load(Data and theAstroglobal). - Turn each
client:*component into anIsland(Islands). - Move actions and middleware to
server/(Actions, Middleware), and the endpoints the report left (Endpoints). - Run
hamur dev, open each page, thenhamur build.
Files and folders
| Astro | Hamur | Status | Differences |
|---|---|---|---|
astro.config.* | hamur.config.ts | different | with defineConfig of hamur and framework; the keys are below |
astro in package.json | hamur and @hamur/adapter-<library> | different | bun remove astro, then bun add hamur @hamur/adapter-react; see Adapters |
src/pages/*.astro and src/pages/**/*.astro | app/pages/** | same | one file per route, written as a component of your library; --write leaves it. See Files and routes |
src/pages/*.ts, src/pages/**/*.ts, src/pages/*.js and src/pages/**/*.js | defineHandler({ route, method, raw: true }) | different | an endpoint; --write writes the handler into server/routes/; see Endpoints |
src/pages/blog/[slug].astro | app/pages/blog/[slug].tsx | same | the same [param] syntax, with the extension of your library. See Files and routes |
src/pages/[...path].astro | app/pages/[...path].tsx | same | a catch-all param is a string[]; [[...path]] also matches the empty path. See Files and routes |
src/pages/404.astro | app/pages/[...slug].tsx or app/pages/_not-found.tsx | different | see Route conventions and A URL no page matches |
src/pages/500.astro | app/error.<ext> | different | the app error page, rendered without a layout; see The error page |
src/layouts/** | app/layouts/<name>.<ext> | different | a layout renders children; a page picks one with meta.layout; see Layouts |
src/components/** | app/components/** | same | import a component by its path. See Co-located components |
src/content/**, src/content.config.ts and src/content.config.js | content/** and content.config.ts | different | with @hamur/content; see Content collections |
src/middleware.ts and src/middleware.js | defineServer({ middleware }) in server/index.ts | different | see Middleware |
src/actions/index.ts | handlers exported from server/index.ts | different | see Actions |
src/env.d.ts | .hamur/ types, written by hamur typegen | different | see TypeScript |
public/ | public/ | same | see Directory structure |
.astro/ | .hamur/ | same | generated. See Directory structure |
dist/ | .output/ | different | the build output; see Build output |
<script> in an .astro file | app/plugins/*.client.ts, or a component | none | Hamur bundles the entry of the app, not a script per page; a script that must run once per page load is a client plugin; see Plugins and hooks |
.astro components
Hamur has no .astro syntax. The frontmatter and the template of an .astro file become the data function and the component of your library.
| Astro | Hamur | Status | Differences |
|---|---|---|---|
the frontmatter fence --- of a page | a load in x.load.ts beside the page, and handlers in server/ | different | server code lives in server/, never in app/; see Data |
the template of an .astro file | the component of your library | none | JSX, a Vue or Svelte template, or a string for html; rewrite it by hand. See Adapters |
<slot /> | children (Vue: the default slot, Svelte: the children snippet) | different | see Adapters |
<slot name="x" /> | a prop that takes an element, or a slot of the library | different | @x folders are parallel route slots, not component slots; see Slots |
<Fragment set:html={html} /> | the library's raw HTML prop, such as dangerouslySetInnerHTML | different | sanitize the string yourself. See Adapters |
class:list | the library's own class syntax | none | write the string or use a class helper such as clsx. See Styling |
<style> scoped to a component | CSS files, CSS modules or the library's scoped style | different | see Styling |
<style is:global> | a global CSS file imported from app/app.<ext> or a layout | different | see Styling |
define:vars | a CSS variable set through style | none | see Styling |
<head> elements in a layout | useHead, or the head of hamur.config.ts | different | there is no <head> element in a component; see Head |
Astro.slots | none | none | pass the content as a prop. See Adapters |
<ViewTransitions />, <ClientRouter /> | app.viewTransition, Link viewTransition | different | Hamur navigates in the browser and can run each navigation in a view transition; see View transitions |
transition:persist | persist on an Island, or a layout that stays mounted | different | see State, children and persisted islands |
transition:name, transition:animate | data-hamur-view-transition and the CSS of the browser | different | see View transitions |
Islands
Every row of the client:* directives is an on value of Island. Island takes a component from app/islands/, and its page sets meta.hydrate: "islands". See Islands and Directives.
| Astro | Hamur | Status | Differences |
|---|---|---|---|
client:load | on="load" of Island from @hamur/adapter-react | same | "load" is the default. See Directives |
client:idle | on="idle" | same | requestIdleCallback, else a 200 ms timer; timeout option. See Lazy hydration |
client:visible | on="visible" | same | IntersectionObserver; rootMargin option. See Lazy hydration |
client:media | on={{ media: "(max-width: 50em)" }} | same | see Lazy hydration |
client:only | on="only" | different | renders fallback on the server and mounts in the browser; the library is the app's adapter. See Directives |
| a component without a directive | a component rendered by the page | different | on an island page it renders on the server only; on a full page it hydrates with the page. See Island pages |
client:* props | props of Island | different | props are serialized; a function prop fails the render. See Islands |
children of a client:* component | children of Island | different | rendered on the server only and never hydrated; on="only" takes none. See State, children and persisted islands |
| components of several libraries on one page | experimental.islands: { libraries } in an html app | different | see html islands and second-library islands; in any other app, one library |
server:defer | ServerIsland from @hamur/adapter-react | same | a component of app/server-islands/ that renders in its own request, with a fallback; see Server islands |
a custom client: directive from an integration | addIslandDirective of hamur/kit | same | see Directives |
output: "static" with islands | an island page with routeRules: { "/blog/**": { prerender: true } } | same | see Prerendered pages |
An island page in code:
import { Island, useData, useRoute } from "@hamur/adapter-react"
import type { PageMeta } from "hamur/app"
import LikeButton from "../../islands/LikeButton"
export const meta = { hydrate: "islands" } satisfies PageMeta
export default function Post() {
const { post } = useData<{ post: { slug: string; title: string } }>()
const { path } = useRoute()
return (
<article>
<h1>{post.title}</h1>
<p>{path}</p>
<Island component={LikeButton} props={{ postId: post.slug }} on="visible" />
</article>
)
}
import { useState } from "react"
export default function LikeButton({ postId }: { postId: string }) {
const [liked, setLiked] = useState(false)
return (
<button type="button" aria-label={`Like ${postId}`} onClick={() => setLiked(!liked)}>
{liked ? "Liked" : "Like"}
</button>
)
}
Data and the Astro global
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 posts = new Map([["hello", { slug: "hello", title: "Hello" }]])
const slugInput = schema<{ slug: string }>(
{ type: "object", properties: { slug: { type: "string" } }, required: ["slug"] },
(value) => {
const slug = (value as { slug?: unknown } | undefined)?.slug
return typeof slug === "string" && slug
? { value: { slug } }
: { issues: [{ message: "A slug is required", path: ["slug"] }] }
},
)
export const listSlugs = defineHandler({
method: "GET",
handler: () => [...posts.keys()],
})
export const getPost = defineHandler({
method: "GET",
input: slugInput,
handler({ slug }) {
const post = posts.get(slug)
if (!post) throw createError({ status: 404, message: "Post not found" })
return post
},
})
import { redirect } from "hamur/app"
import type { Entries, Load } from "hamur/app"
import { getPost, listSlugs } from "../../../server/index.ts"
export const entries = (async () => (await listSlugs()).map((slug) => ({ slug }))) satisfies Entries
export const load = (async ({ params }) => {
if (params.slug === "old") return redirect("/blog/hello", 301)
return { post: await getPost({ slug: params.slug as string }) }
}) satisfies Load
| Astro | Hamur | Status | Differences |
|---|---|---|---|
Astro.props of a page | meta.props: true, or useRoute().params | different | a page has no props by default; meta.props: true passes the route's params as props, see Page meta |
Astro.props of a component | the component's own props | same | see Adapters |
Astro.params | useRoute().params in a component, params of the load context | same | a catch-all is a string[]. See Files and routes |
getStaticPaths() | entries in the page's x.load.ts | different | it returns one object of params per path; dynamicParams = false makes them the only paths; see Pages to prerender |
getStaticPaths with props | the load, which reads the data again | different | the prerender shares the answers of one run, so a GET handler called with one input runs once. See Shared data |
paginate() | entries with a page param | none | write the pages as entries: [...Array(n).keys()].map((page) => ({ page: String(page + 1) })). See Pages to prerender |
Astro.url | useRoute(), url of the load context | different | useRoute() has path, fullPath, query and hash; in a server file getRequestURL(event) of hamur/server. See The router |
Astro.url.searchParams | useRoute().query | different | an object; see Search params |
Astro.request | event.request | same | a Web Request; event is ctx.event of a handler and of a load on the server. See Handlers |
Astro.cookies.get(name) | useCookie(name) in a component, getCookie(event, name) on the server | different | see State |
Astro.cookies.set(name, value, options) | setCookie(event, name, value, options), or useCookie | different | setCookie of hamur/server. See State |
Astro.cookies.delete(name) | deleteCookie(event, name) | different | see State |
Astro.locals | event.context | different | a middleware writes event.context.user, a handler and a load read it; type the keys with HamurEventContext, see Middleware |
Astro.redirect(location, status) | redirect("/x", 301) from hamur/app | same | return or throw it from a load, route middleware, a request step or a handler. See redirect |
Astro.rewrite(path) | rewrite("/x") from hamur/app | same | the address stays; a loop of six rewrites answers 508; see rewrite |
Astro.response.status, statusText | setResponseStatus(event, status), or createError({ status }) | different | see Errors |
Astro.response.headers | setHeaders of the load context, event.response.headers in a handler | different | a load sets headers on the document only; in a route a headers rule does it by pattern, see Route rules |
Astro.clientAddress | getRequestIP(event) of hamur/server | different | behind a proxy, set trustedHops; see getRequestIP |
Astro.site | site.url | different | with @hamur/seo; see Site config |
Astro.generator | none | none | the page has no generator tag; add one with useHead if you want it. See Head |
Astro.currentLocale, Astro.preferredLocale | useI18n() of @hamur/i18n, event.context.locale on the server | different | see Internationalization |
Astro.getActionResult() | useAction(fn) | different | see Actions |
Astro.self | none; a component imports itself | none | see Adapters |
Astro.callAction() | the handler, called as a function on the server | different | see Calling a handler |
export const prerender = true | meta.rules: { prerender: true }, or a prerender route rule | different | there is no prerender export; see Prerendering a page without params |
export const prerender = false | the default | different | a page renders on each request unless a rule prerenders it; ssr: false makes it a single-page route. See Rendering modes |
Assets and environment
| Astro | Hamur | Status | Differences |
|---|---|---|---|
Image from astro:assets | Img from @hamur/image/react | different | with @hamur/image in modules; alt is required, width and height default to the file's size; see Showing an image |
Picture from astro:assets | Picture from @hamur/image/react | same | see Picture |
getImage() | getImage(src, modifiers) from @hamur/image/server | same | for a handler, an OpenGraph tag or a component; see Image URLs in a handler |
image.domains, image.remotePatterns | image.domains | different | see Remote images and limits |
image.service | image.provider | different | see Providers |
experimental.fonts | @hamur/fonts | different | the families go under fonts; see Fonts |
import.meta.env.PUBLIC_X | useRuntimeConfig().public.x, or #hamur/env/public | different | see Environment |
import.meta.env.SECRET | #hamur/env/private | different | server only; the build fails if client code imports it. See Private and public values |
astro:env/server | #hamur/env/private, typed by defineEnv of hamur | different | see app/env.ts |
astro:env/client | #hamur/env/public | different | read once, when the page loads. See Private and public values |
envField.string({ context: "server", access: "secret" }) | { schema } in defineEnv, with no public | different | any Standard Schema, or a function that throws on a bad value. See app/env.ts |
envField.number({ context: "client", access: "public" }) | { public: true, schema } | different | see app/env.ts |
envField with optional: true or default | default in the entry | same | default replaces an unset value, not an empty one. See app/env.ts |
getSecret() | #hamur/env/private | different | the value is read once, at server start, so an invalid one stops the start. See When the value is read |
The environment file is app/env.ts:
import { defineEnv } from "hamur"
const port = (raw: string | undefined): number => {
const value = Number(raw)
if (!Number.isInteger(value)) throw new Error("must be a number")
return value
}
export default defineEnv({
API_KEY: {},
PORT: { schema: port, default: "3000", description: "Port of the HTTP server" },
GA_ID: { public: true, description: "Analytics id" },
SHOW_DEBUG: { public: true, static: true, schema: (raw) => raw === "true", default: "false" },
})
Actions
An Astro action is a typed function that a form or a script calls. In Hamur it is a handler: a function you write with defineHandler, export from server/index.ts and import in a page from #server. A form posts to it, and it works without JavaScript.
import { defineHandler } from "hamur/server"
import { schema } from "../../migrate-next/server/schema.ts"
const likeInput = schema<{ postId: string }>(
{ type: "object", properties: { postId: { type: "string" } }, required: ["postId"] },
(value) => {
const postId = (value as { postId?: unknown } | undefined)?.postId
return typeof postId === "string" && postId
? { value: { postId } }
: { issues: [{ message: "A post is required", path: ["postId"] }] }
},
)
export const like = defineHandler({
input: likeInput,
handler({ postId }, { event }) {
event.log.info("liked", { postId })
return { postId, likes: 1 }
},
})
| Astro | Hamur | Status | Differences |
|---|---|---|---|
defineAction({ handler }) | defineHandler({ handler }) from hamur/server | different | a module-level export const of server/, written as an object literal; see Defining a handler |
input: z.object({}) | input: schema | different | any Standard Schema; a failed check answers 400 with data.issues and data.values; see Validation |
accept: "form" | <Form action={fn}> | different | the form is decoded before the handler; see The Form component |
accept: "json" | the default | same | a handler is called with a typed input. See Calling a handler |
actions.like(input) in a script | like(input), imported from #server | different | in the browser the call is a request, on the server a function call. See Calling a handler |
actions.like in a <form action> | <Form action={like}> | different | works without JavaScript: the form posts to the page with ?_fn=<id>. See Without JavaScript |
Astro.getActionResult(actions.like) | useAction(like) | different | state, failure, error, pending and result of useAction from @hamur/adapter-react. See Pending state and optimistic UI |
isInputError(error) | failure of useAction(fn) | different | a 400 with issues is the failure; see Reading the result |
ActionError({ code }) | throw createError({ status }) from hamur/server, or fail(status, data) | different | fail takes 400 to 499 and returns the data to the form; see fail |
isActionError(error) | isActionFailure(value) | different | see isActionFailure |
return redirect() after a form | return redirect("/x") from hamur/app | same | a form post is answered with 303. See Without JavaScript |
getActionContext(context) | ctx.event of the handler | different | see Defining a handler |
actions.blog.like (nested) | one export per handler | different | the name is the name of the export. See Id and name |
.orThrow() | await like(input) | same | a failed call throws on the client; see Errors and redirects on the client |
an action as a public endpoint at /_actions/like | a handler with a route, or the one at /_hamur/fn/<id> | different | authorize inside every handler; see Every handler is a public endpoint |
security.checkOrigin | server.originCheck | different | server.originCheck.allow lists extra origins, false turns the check off; see Sessions and security |
Content collections
| Astro | Hamur | Status | Differences |
|---|---|---|---|
src/content.config.ts, defineCollection | content.config.ts, defineCollection and defineContentConfig from @hamur/content | different | at the app root, with collections in the default export and type: "page" or "data"; see Set it up |
loader: glob({ pattern, base }) | source of the collection, or glob | same | source is the glob loader; see Sources and paths |
loader: file("data.json") | file(path) of @hamur/content, or a source | same | an array gives one entry per item; see Loaders |
| a custom loader | a loader: { name, load } | different | it calls store.set; it runs at build and in hamur dev, never at run time; see Loaders |
schema: z.object({}) | schema | same | any Standard Schema; image() is the schema of an image field; see Schemas |
reference(name) | a field that holds the id, read with a second queryCollection | none | there is no reference type. See Queries |
getCollection(name) | queryCollection(name).all() from @hamur/content/query | different | a query builder; where, order, limit, select, count; see Queries |
getCollection(name, filter) | queryCollection(name).where(field, op, value) | different | see Queries |
getEntry(name, id) | queryCollection(name).path(path).first() | different | see Queries |
getEntries(refs) | queryCollection(name).where("id", "IN", ids).all() | different | see Queries |
entry.data | the entry's fields | different | the fields sit beside id, path and body; collection, id and body are reserved names in frontmatter. See Sources and paths |
render(entry) | ContentRenderer from @hamur/content/react | different | with value and components; renderEntry(entry) of @hamur/content/render gives { html, headings, ast }; see Render an entry |
a catch-all page that calls getEntry | useContentPage(collection) | different | sets the head from the entry and throws a 404 when none matches; see A page for each entry |
| live content collections | live collections | different | see Live collections |
| MDX | none | none | Markdown components cover the same job; see Why there is no MDX and Markdown components |
@astrojs/markdown-remark options | markdown | different | remark and rehype plugins go under markdown; see Plugins |
| Shiki code highlighting | markdown highlighting | different | see Highlighting |
Middleware
src/middleware.ts becomes the middleware list of defineServer. The list runs before every request, in the order written. There is no sequence: the list is the sequence.
import { redirect } from "hamur/app"
import { defineMiddleware, getCookie } from "hamur/server"
export const session = defineMiddleware(({ event }) => {
event.context.user = getCookie(event, "user") ?? null
})
export const admin = defineMiddleware(({ event }) => {
if (!event.context.user) throw redirect("/login")
})
import { defineServer } from "hamur/server"
import { admin, session } from "./middleware.ts"
export { getPost, listSlugs } from "./blog.ts"
export { like } from "./like.ts"
export { rss } from "./rss.ts"
export default defineServer({
middleware: [session, { route: "/admin/**", handler: admin }],
})
| Astro | Hamur | Status | Differences |
|---|---|---|---|
defineMiddleware((context, next) => …) | defineMiddleware(({ event, next }) => …) from hamur/server | different | see Middleware |
export const onRequest | the middleware list of defineServer | different | in server/index.ts. See Middleware |
sequence(a, b) | middleware: [a, b] | same | outermost first. See Middleware |
context.locals.user = … | event.context.user = … | different | the handler and the load read it. See Middleware |
await next() | await next() | same | the code after it sees the answer; a returned Response replaces it. See Middleware |
return new Response() | return a value | same | returning a value ends the request with it. See Middleware |
return context.redirect("/login") | throw redirect("/login") from hamur/app | different | a thrown redirect() redirects. See Middleware |
return next("/other"), context.rewrite("/other") | return rewrite("/other") from hamur/app | same | the address stays. See rewrite |
a check on context.url.pathname | { route: "/admin/**", handler } | different | there is no matcher; a list entry with a route runs only under it. See Middleware |
| a middleware that guards an action | handlerMiddleware, or middleware of the handler | different | a request step guards the document; the handler's list guards every call; see Handlers: middleware |
| middleware of a prerendered page | none | none | a prerendered page is a file; a guard on it belongs to the host, or the page is not prerendered. See Rendering modes |
context.isPrerendered | import.meta.prerender | different | true while hamur generate renders. See import.meta.env and import.meta.prerender |
Endpoints
An endpoint file src/pages/rss.xml.ts becomes a handler with a route and raw: true. It gets the request as event.request and returns a Response. hamur migrate astro --write does this for an endpoint that reads only params, url and request: each exported method becomes a handler named <method><Words> (getApiItemsId) in server/routes/, with [id] written as :id and [...path] as **:path. A file or folder that starts with _, a segment such as post-[id], and an ALL export are left for you.
import { defineHandler } from "hamur/server"
export const rss = defineHandler({
route: "/rss.xml",
method: "GET",
raw: true,
handler: () => new Response('<rss version="2.0"></rss>', { headers: { "content-type": "application/xml" } }),
})
| Astro | Hamur | Status | Differences |
|---|---|---|---|
src/pages/api/x.ts with export const GET | a handler with route: "/api/x" and method: "GET" | different | exported from server/index.ts; see A handler with a route |
export const POST: APIRoute | a handler with method: "POST" | different | one handler for each method. See A handler with a route |
export const ALL | one handler for each method | none | see A handler with a route |
({ request, params, locals }) => Response | (input, { event }) => Response with raw: true | different | event.request, the route params in getRouterParam(event, name), event.context; see raw |
new Response(JSON.stringify(x)) | return the object | different | a handler returns a value, which is sent as JSON; raw: true returns a Response as written. See What a raw handler returns |
a static endpoint, built at astro build | a GET handler with prerender | different | see Prerender |
getStaticPaths of an endpoint | prerender: { inputs } of the handler | different | see Prerender |
export const prerender = false in an endpoint | the default | different | see Prerender |
rss() of @astrojs/rss | a raw handler, or @hamur/seo feeds | different | see Feeds |
sitemap() of @astrojs/sitemap | @hamur/seo | different | see Sitemap |
Modules
| Astro | Hamur | Status | Differences |
|---|---|---|---|
defineConfig of astro/config | defineConfig from hamur | different | the config is hamur.config.ts; see Config keys |
astro:content | queryCollection of @hamur/content/query, defineCollection of @hamur/content | different | see Content collections |
astro:actions | defineHandler from hamur/server | different | see Actions |
astro:middleware | defineMiddleware from hamur/server | different | see Middleware |
astro:transitions, astro:transitions/client | app.viewTransition | different | see View transitions |
astro:i18n | useI18n() of @hamur/i18n | different | see Internationalization |
Integrations and adapters
| Astro | Hamur | Status | Differences |
|---|---|---|---|
integrations: [react()] | framework: "react" and @hamur/adapter-react | different | one library for the app; see Adapters |
astro add <name> | hamur module add <name> | different | see hamur module |
an integration's hooks (astro:config:setup, astro:build:done) | defineModule of hamur/kit | different | a module has setup and build hooks; see Modules |
updateConfig, injectRoute, addMiddleware of an integration | the kit's extendPages, addServerMiddleware and others | different | see The kit |
@astrojs/mdx | none | none | see Why there is no MDX |
@astrojs/sitemap | @hamur/seo | different | see SEO |
@astrojs/db | @hamur/db | different | SQL migrations; see Database |
@astrojs/tailwind and other CSS tools | @hamur/css | different | see Styling |
@astrojs/node, adapter: node() | preset: "node" | same | see Presets |
@astrojs/cloudflare | preset: "cloudflare" | same | cloudflare-static and cloudflare-pages also exist; see Presets |
@astrojs/vercel | preset: "vercel" | same | see Presets |
@astrojs/netlify | preset: "netlify" | same | see Presets |
output: "static" | preset: "static" | same | every route is prerendered; see Rendering modes |
output: "server" | a server preset | same | see Presets |
output: "hybrid" (Astro 4) or prerender per page | routeRules with prerender | different | see Route rules and prerender |
i18n routing | i18n with @hamur/i18n in modules | different | messages use ICU MessageFormat; see Internationalization |
astro dev | hamur dev | same | see Dev server |
astro build | hamur build | same | see CLI |
astro preview | hamur preview | same | see CLI |
astro check | hamur typecheck | different | see CLI |
| the dev toolbar | @hamur/devtools | different | see Devtools |
Config keys
import { defineConfig } from "hamur"
import image from "@hamur/image"
import content from "@hamur/content"
import seo from "@hamur/seo"
export default defineConfig({
framework: "react",
preset: "node",
experimental: { islands: true },
modules: [image, content, seo],
app: { baseURL: "/docs/", trailingSlash: "redirect" },
routeRules: {
"/old/:slug": { redirect: { to: "/blog/:slug", status: 301 } },
"/blog/**": { prerender: true },
},
})
| Astro | Hamur | Status | Differences |
|---|---|---|---|
site | site.url, with @hamur/seo | different | see Site config |
base | app.baseURL | same | it ends with /. See Configuration |
trailingSlash | app.trailingSlash | different | "ignore", "redirect", "always" or "strict"; see Files and routes |
redirects | routeRules[source] = { redirect } | different | { redirect: { to, status } }; a long list is a redirects file |
output, adapter | preset | different | see Presets |
integrations | modules | different | see Modules |
server.port, server.host | devServer, hamur dev --port, --host | different | see CLI |
outDir | outputDir | same | see Build output |
publicDir | publicDir | same | see Configuration |
srcDir | srcDir | same | see Configuration |
vite | build, or @hamur/vite-compat | different | build is Bun.build options; see Vite plugins |
markdown | markdown | different | see The markdown key |
image | image | different | see Images |
env.schema | app/env.ts | different | see Environment |
i18n | i18n | different | see Set it up |
devToolbar | @hamur/devtools in modules | different | see Devtools |
prefetch | app.link, Link prefetch | different | see Prefetch |
experimental | experimental | different | see Experimental |