Skip to content

Instantly share code, notes, and snippets.

@brianleroux
Last active September 18, 2018 22:29
Show Gist options
  • Save brianleroux/38a6f126edd47861084ecc3efe946541 to your computer and use it in GitHub Desktop.
Save brianleroux/38a6f126edd47861084ecc3efe946541 to your computer and use it in GitHub Desktop.
what if I told u
import data from '@architect/data'
import App from '@architect/shared/app'
import render from 'preact-to-string'
import {h} from 'preact'
/**
* ssr preact from a lambda
* if, instead of index.js, you have index.jsx OR index.tsx arc will automatically transpile the code
*/
export async function handler(req) {
let notes = await data.all({ns:'notes'})
let body = render(<App path={req.path} state={notes} />)
// future: support returning headers/body and promises
return `<!doctype html><html><body>${body}</body></html>`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment