Skip to content

ProjectEvergreen/greenwood-demo-adapter-vercel

Repository files navigation

greenwood-demo-adapter-vercel

A demonstration repo for deploying a full-stack Greenwood app with Vercel static hosting and Serverless + Edge functions.

Setup

To run locally

  1. Clone the repo
  2. Run npm ci

You can now run these npm scripts

  • npm run dev - Start the demo with Greenwood local dev server
  • npm start - Start the demo with a production Greenwood build

👉 Note: If deploying to your own Vercel instance, make sure you set the NodeJS version to 18.x in your Vercel project's General settings.

Demo

This repo aims to demonstrate a couple of Greenwood's features (API Routes and SSR pages) leveraging Vercel's serverless and edge function capabilities, focused on using Web Components (WCC) and Web Standards to deliver the content for the demo.

Status

Feature Greenwood Serverless Edge
API Routes
SSR Pages

You can see the live demo at https://greenwood-demo-adapter-vercel.vercel.app/.

Serverless

The serverless demos include the following examples:

API Routes

  • /api/greeting?name{xxx} - An API that returns a JSON response and optionally uses the name 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.

SSR Pages

  • /products/ - SSR page for rendering Greenwood pages.

Edge

TODO

API Routes

TODO

SSR page

TODO

Adapter Implementation Thoughts / Questions

  1. Will need to generate the api/ folder on-demand / as part of the build instead of hardcoding, likely from manifest.json
  2. How to manage vercel configuration (e.g. redirects for pages)? Auto generate, auto merge into vercel.json?
  3. How to best manage local dev (runtime "compliance") - just for production builds
    • proxy vercel cli dev option?
    • should use src/ or public/? depends on dev vs production mode? Interestingly, the manual way only worked deployed when using public/
  4. Make sure to spread all headers / response properties in Vercel functions adapter output
  5. Keep it as an experimental feature for 1.0 (or per platform?)
  6. Will SSR pages need access to the request object?

About

A demonstration repo for deploying a full-stack Greenwood app with Vercel static hosting and Serverless + Edge functions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published