Skip to content

Commit

Permalink
Lit SSR (#2)
Browse files Browse the repository at this point in the history
* lit greeting component example in API endpoint

* pre create public/api/assets directory

* restore card component

* restore home page and fragment API

* restore search page

* update README
  • Loading branch information
thescientist13 authored Oct 12, 2023
1 parent 5fbf9b3 commit 65856fa
Show file tree
Hide file tree
Showing 13 changed files with 662 additions and 172 deletions.
52 changes: 9 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# greenwood-demo-adapter-vercel

A demonstration repo for deploying a full-stack [**Greenwood**](https://www.greenwoodjs.io/) app with Vercel static hosting and Serverless + Edge functions.
A demonstration repo for deploying a full-stack [**Greenwood**](https://www.greenwoodjs.io/) app using [Lit](https://lit.dev/) SSR with Vercel static hosting and Serverless + Edge functions.

You can see the live demo at [https://greenwood-demo-adapter-vercel-lit.vercel.app/](https://greenwood-demo-adapter-vercel-lit.vercel.app/).

> _It is based on [this](https://github.com/ProjectEvergreen/greenwood-demo-adapter-vercel) Greenwood demo._
## Setup

Expand All @@ -14,51 +18,13 @@ You can now run these npm scripts

> 👉 **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](https://www.greenwoodjs.io/docs/api-routes/) and [SSR pages](https://www.greenwoodjs.io/docs/server-rendering/#routes)) leveraging Netlify'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/](https://greenwood-demo-adapter-vercel.vercel.app/).

## Serverless

The serverless demos include the following examples:

### API Routes

-[`/api/greeting?name{xxx}`](https://greenwood-demo-adapter-vercel.vercel.app/api/greeting) - An API that returns a JSON response and optionally uses the `name` query param for customization. Otherwise returns a default message.
-[`/api/fragment`](https://greenwood-demo-adapter-vercel.vercel.app/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/`](https://greenwood-demo-adapter-vercel.vercel.app/products/) - SSR page for rendering Greenwood pages.

## Edge

TODO

### API Routes

TODO

### SSR page

TODO

## Adapter Implementation Thoughts / Questions
|SSR Pages | 🚫 |||

1. [x] Will need to generate the _api/_ folder on-demand / as part of the build instead of hardcoding, likely from _manifest.json_
1. [x] How to manage vercel configuration (e.g. redirects for pages)? Auto generate, auto merge into _vercel.json_?
1. [x] 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/_
1. [x] Make sure to spread all headers / response properties in netlify functions adapter output
1. [ ] Keep it as an experimental feature for 1.0 (or per platform?)
1. [ ] Will SSR pages need access to the request object?
### Known Issues
1. [ ] [Lit SSR does not support `async`` component work](https://github.com/thescientist13/greenwood-demo-adapter-vercel-lit/issues/3)
1. [ ] [Declarative Shadow DOM support](https://github.com/thescientist13/greenwood-demo-adapter-vercel-lit/issues/4)
2 changes: 2 additions & 0 deletions greenwood.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { greenwoodPluginAdapterVercel } from '@greenwood/plugin-adapter-vercel';
import { greenwoodPluginRendererLit } from '@greenwood/plugin-renderer-lit';

export default {
plugins: [
greenwoodPluginRendererLit(),
greenwoodPluginAdapterVercel()
]
};
Loading

0 comments on commit 65856fa

Please sign in to comment.