Mastro 👨‍🍳 Docs

Search results

Blog Community GitHub   Stoat Chat   Discord   Bluesky

No dependencies. No build step. Just a simple web framework.

Mastro is a web framework and static site generator for people who care about their users and web standards. It’s simple, pragmatic, and implemented in just ~800 lines of TypeScript.

Use JavaScript/TypeScript’s mature tooling to build fast server-rendered websites. Instead of drowning in layers of abstractions, work directly with the browser and your JavaScript runtime – Node.js, Deno, Bun, or Workers.

Get started Docs ☆ Mastro on GitHub

As seen on the Internet!

The New Stack

TypeScript.fm

That HTML blog

Mastro's source code is extremely readable.
Erik Onarheim
A library worth checking out!
Jared White

Minimal yet powerful

No dependencies, no build step

Learn more Get started

routes/hello.server.js
// Respond to a HTTP GET with plain text
export const GET = () => {
  return new Response("Hello World");
}
Copied!
routes/api.server.ts
import { jsonResponse } from "@mastrojs/mastro";
import { addComment } from "../models/comments.ts";

// Respond to a HTTP POST with JSON
export const POST = async (req: Request) => {
  const data = await req.json();
  const comment = await addComment(data);
  return jsonResponse(comment);
};
Copied!
import { readMarkdownFiles } from "@mastrojs/markdown";
import { html, htmlToResponse } from "@mastrojs/mastro";
import { Layout } from "../components/Layout.ts";

// Respond with HTML
export const GET = async () => {
  const posts = await readMarkdownFiles("posts/*.md");
  return htmlToResponse(
    Layout({
      title: "My blog",
      children: posts.map((post) => html`
        <p>${post.meta.title}</p>
      `)
    })
  );
};
Copied!
import { html, type Html } from "@mastrojs/mastro";

interface Props {
  title: string;
  children: Html;
}

export const Layout = (props: Props) =>
  html`
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <title>${props.title}</title>
      </head>
      <body>
        <h1>${props.title}</h1>
        ${props.children}
      </body>
    </html>
  `;
Copied!

Try Mastro online More examples Source of this website

Easy for beginners

Put your first website live without installing anything on your computer: The popular VS Code editor also runs in the browser.

Launch Mastro in your browser

Start with learning HTML and CSS. Then build a static blog and a to-do list app with JavaScript. Finally, serve a REST API.

Follow the guide

Powerful for experienced developers

I’ve seen things you wouldn’t believe. Megabytes of JavaScript on fire in the browser. I watched towers of complex abstractions collapse upon themselves. All those websites will be lost in time, like tears in rain. Time to let them die.

Install Mastro Docs ☆ Mastro on GitHub

Fast for everyone

Great UX: websites built with Mastro are fast – even on low-end devices on 3G.

  • 100% Performance
  • 100% Accessibility
  • 100% SEO

Great DX: dev server starts instantly, and SSG is fast – e.g. for 500 markdown files:

Mastro 0.5s  🏁
11ty 0.7s
Astro 2.2s
Next.js 16.3s

Interactive user interfaces

For client-side interactivity in the browser, either use plain JavaScript, or add a library like HTMX, Alpine, Unpoly, ArrowJS, or Reactive Mastro, which allows you to share templates with the server.

Reactive Mastro

A foundation to build upon

The minimal Mastro core package doesn’t come “batteries included”, but it’s built to be extended.

Extensions / plugins

Escape the frontend treadmill

Most JavaScript frameworks and complex build systems were designed to solve problems that no longer exist.

Why Mastro?

Join the community

We’re building an inclusive community, where people of all kinds of backgrounds and experience levels feel welcome and safe, and help each other. A place to ask questions and learn new things.

Want help or chat?

Talk to us on Bluesky, GH Discussions, or:

Discord Stoat

Star us on GitHub!

Every star and every share helps.

GitHub Report a bug


Stay updated 👨‍🍳

Follow us on Bluesky, or add our blog to your RSS reader (feed link).