https://github.com/lukeed/preact-cli-ssr
A quick demo for adding SSR to a Preact CLI app
https://github.com/lukeed/preact-cli-ssr
express preact preact-cli preact-demos ssr
Last synced: 3 months ago
JSON representation
A quick demo for adding SSR to a Preact CLI app
- Host: GitHub
- URL: https://github.com/lukeed/preact-cli-ssr
- Owner: lukeed
- License: mit
- Created: 2017-11-03T21:50:01.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-30T18:20:07.000Z (over 7 years ago)
- Last Synced: 2024-06-29T00:19:03.924Z (over 1 year ago)
- Topics: express, preact, preact-cli, preact-demos, ssr
- Language: JavaScript
- Homepage: https://preact-cli-ssr.now.sh/
- Size: 99.6 KB
- Stars: 79
- Watchers: 4
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# Preact CLI SSR Demo
> A quick demo that illustrates how to add SSR to a Preact CLI app
This demo was built with [`preact-cli`](https://github.com/developit/preact-cli), using the [`default`](https://github.com/preactjs-templates/default) template.
It's powered by an Express server with `gzip` compression... nothing special there.
Because of how `preact-cli` produces the `build` directory, the server must respect static/file requests first. This also means that your `build/index.html` will _always_ be served on the `/` request. This isn't a bad thing, it's just something to be aware of!
**Important:** This server behaves exactly like Preact CLI's [prerendering](https://github.com/developit/preact-cli#pre-rendering). This means that if you (or your libraries) have references to `window` or `document`, you must wrap them in conditional statements or include a shim.
## Install
```sh
$ git clone https://github.com/lukeed/preact-cli-ssr
$ npm install
$ npm run build
$ npm start
```
## License
MIT © [Luke Edwards](https://lukeed.com)