Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/frameworks.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,22 @@
"measurements": [{ "type": "ssr" }]
}
},
{
"name": "mastro",
"displayName": "Mastro",
"frameworkPackage": "jsr:@mastrojs/mastro",
"focusedFramework": false,
"starter": {
"package": "starter-mastro",
"buildScript": "generate",
"buildOutputDir": "generated",
"measurements": [
{ "type": "install", "runFrequency": 5 },
{ "type": "build", "runFrequency": 5 },
{ "type": "dependencies" }
]
}
},
{
"name": "solid-start",
"displayName": "SolidStart",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"build:sveltekit": "pnpm --filter starter-sveltekit build",
"dev:astro": "pnpm --filter starter-astro dev",
"build:astro": "pnpm --filter starter-astro build",
"dev:mastro": "pnpm --filter starter-mastro dev",
"build:mastro": "pnpm --filter starter-mastro build",
"dev:solid-start": "pnpm --filter starter-solid-start dev",
"build:solid-start": "pnpm --filter starter-solid-start build",
"build:app-astro": "pnpm --filter app-astro build",
Expand Down
3 changes: 3 additions & 0 deletions packages/starter-mastro/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["ms-fast.fast-tagged-templates"]
}
40 changes: 40 additions & 0 deletions packages/starter-mastro/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Mastro Template Basic for Node.js

This is a basic TypeScript template for [Mastro](https://mastrojs.github.io) when using [Node.js](https://nodejs.org).

Click the green **Use this template** button in the top right to create your own copy of this repository. Then clone the **Code** to your computer.

## Run locally

If you have multiple projects on your computer that require different Node.js versions, you should install a tool to manage those version for you; for example [Volta](https://volta.sh/) (see [pnpm Support](https://docs.volta.sh/advanced/pnpm)).

Mastro requires Node.js >=24 (unless you want to install a [`URLPattern` polyfill](https://www.npmjs.com/package/urlpattern-polyfill)).

[JSR recommends](https://jsr.io/docs/npm-compatibility#installing-and-using-jsr-packages) to use `pnpm`.

The first time, you need to:

pnpm install

After that, to start the server:

pnpm run start

and open <http://localhost:8000> in your browser.

To generate the whole static site (this will create a `generated` folder):

pnpm run generate

## Next steps

To see how Mastro works, [follow the guide](https://mastrojs.github.io/guide/server-side-components-and-routing/).

To make sure you're using the latest Mastro packages:

pnpm update "@mastrojs/*" --latest

## Deploy to production

- [Deploy static site](https://mastrojs.github.io/guide/deploy/#deploy-static-site-with-ci%2Fcd)
- [Deploy server](https://mastrojs.github.io/guide/deploy/#deploy-server-to-production)
21 changes: 21 additions & 0 deletions packages/starter-mastro/components/Layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { type Html, html } from '@mastrojs/mastro'

interface Props {
children: Html
title: string
}

export const Layout = (props: Props) => html`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>${props.title}</title>
<link rel="stylesheet" href="/styles.css" />
</head>
<body>
<h1>${props.title}</h1>
${props.children}
</body>
</html>
`
20 changes: 20 additions & 0 deletions packages/starter-mastro/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "starter-mastro",
"type": "module",
"scripts": {
"dev": "node --watch server.ts",
"build": "node node_modules/@mastrojs/mastro/src/generator.js",
"check": "tsc"
},
"dependencies": {
"@mastrojs/mastro": "jsr:^0",
"@remix-run/node-fetch-server": "^0.11"
},
"devDependencies": {
"@types/node": "^24",
"typescript": "^5"
},
"engines": {
"node": ">=24.12"
}
}
10 changes: 10 additions & 0 deletions packages/starter-mastro/routes/index.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { html, htmlToResponse } from '@mastrojs/mastro'
import { Layout } from '../components/Layout.ts'

export const GET = (_req: Request) =>
htmlToResponse(
Layout({
title: 'Hello World',
children: html` <p>Welcome!</p> `,
}),
)
26 changes: 26 additions & 0 deletions packages/starter-mastro/routes/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
html {
font-family: sans-serif;
}

h1,
h2,
h3,
h4,
h5,
h6 {
word-break: break-word;
text-wrap-style: pretty;
}

p {
hyphens: auto;
word-break: break-word;
}

img {
max-width: 100%;
}

@view-transition {
navigation: auto;
}
15 changes: 15 additions & 0 deletions packages/starter-mastro/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as http from 'node:http'
import { createRequestListener } from '@remix-run/node-fetch-server'
import mastro from '@mastrojs/mastro/server'

const port = 8000

const server = http.createServer(createRequestListener(mastro.fetch))

server.on('error', (e) => {
console.error(e)
})

server.listen(port, () => {
console.log(`Server running at http://localhost:${port}`)
})
15 changes: 15 additions & 0 deletions packages/starter-mastro/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"allowImportingTsExtensions": true,
"module": "NodeNext",
"moduleResolution": "nodenext",
"noEmit": true,
"skipLibCheck": true,
"strict": true,
"verbatimModuleSyntax": true,

"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true
}
}
133 changes: 133 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.