Razzle Preact Example
How to use
Download the example or clone the whole project:
curl https://codeload.github.com/jaredpalmer/razzle/tar.gz/master | tar -xz --strip=2 razzle-master/examples/with-preact
cd with-preact
Install it and run:
yarn install
yarn start
Idea behind the example
This shows how to setup Preact with Razzle.
Here is a list of changes from Razzle's base template:
- Install
babel-plugin-transform-react-jsx
as a devDependency.
- Extend Razzle's babel config with a custom
.babelrc
- Install
preact
and preact-render-to-string
- Remove
react
, react-dom
, react-router-dom
entirely
- Update
server.js
to use preact-render-to-string
's render
function. Also remove the <div id="root">
element from our html template since Preact can render to the body.