v0.34.0-alpha.2
Pre-releaseOverview
This release in the v0.34.0 release line adds support for dynamic file based routing, adds support for Node 24 in the Vercel adapter (as the default), and introduces a breaking change around placeholders for layouts content templating.
# npm
$ npm i -D @greenwood/cli@alpha
# Yarn 1.x (classic)
$ yarn upgrade @greenwood/cli@alpha --dev
# pnpm
$ pnpm i -D @greenwood/cli@alphaChangelog
https://github.com/ProjectEvergreen/greenwood/issues?q=label%3Av0.34.0%20label%3Aalpha.2
- feature(cli): #882 dynamic SSR and API routing
- feature(adapters): #1533 add node 24 runtime option vercel adapter
- feature(plugins): #1539 import map extensions option for raw import plugin
- feature(cli): #1476 use
<output>tag for layout templating
Features (Early Access)
Dynamic Routing
In this release, Greenwood now support dynamic file based routing for SSR pages and API routes.
SSR Pages
To serve requests like /blog/:slug/, create a route like this at src/pages/blog/[slug].js (or .ts)
type BlogPostPageProps = {
params: {
slug: string;
};
};
export default class BlogPostPage extends HTMLElement {
#slug: string;
constructor({ params }: BlogPostPageProps) {
super();
this.#slug = params?.slug;
}
connectedCallback() {
this.innerHTML = `
<body>
<h1>${this.#slug}</h1>
</body>
`;
}
}API Routes
To serve requests like /api/product/:id, create a route like this at src/pages/api/products/[id].js (or .ts)
type ProductProps = {
params: {
id: string;
};
};
export async function handler(request: Request, { params }: ProductProps): Promise<Response> {
return new Response(`Product id is => ${params.id}`);
}This is also supported in all our adapter plugins for Vercel, Netlify, and AWS.
See the docs PR for more information / details - ProjectEvergreen/www.greenwoodjs.dev#261
Breaking Changes
Vercel Adapter
To align with Vercel hosting, the default runtime version for the adapter is now node24.x.
Layouts Templating
To address issues with server-rendering and Web Components, the layout templating placeholder has been changed to something more semantic and valid HTML
<-- before -->
<content-outlet></content-outlet>
<page-outlet></page-outlet><!-- after -->
<output for="content"></outlet>
<output for="page"></outlet>Known Issues
N / A