A demonstration repo for using Greenwood on a server using the hosting platform Fly.io.
- Clone this repository
- Run
npm ci
- Run
npm run develop
to start the dev server
The main demo is hosted at https://restless-river-5040.fly.dev.
/
- Home page that demonstrates the below API routes/artists
- Artists page that makes a backendfetch
call to render SSR artists data on the page/api/greeting?name{xxx}
- An API that returns a JSON response and optionally uses thename
query param for customization. Otherwise returns a default message./api/fragment
- An API for returning fragments of server rendered Web Components as HTML, that are then appended to the DOM. The same card component used in SSR also runs on the client to provide interactivity, like event handling.
Below is how to self host your own Greenwood app on Fly.io.
First make a couple changes to your Greenwood project
- Have the following npm scripts setup in your package.json
"scripts": { "...": "...", "build": "greenwood build", "start": "greenwood serve" }
- Make sure @greenwood/cli package is a dependency in your package.json
"dependencies": { "@greenwood/cli": "~0.28.2" }
Following this guide, after installing and logging into the Fly CLI, do the following:
- Run
fly launch
- Run
fly deploy
That's it! 🎉