This is a fully working example of Next.js running on Preact instead of React.
This reduces the base JavaScript weight of pages to 30kb (or far lower with additional Webpack optimizations).
Clone this repo and run npm install
:
git clone git@github.com:developit/next-preact
The example takes advantage of npm/yarn aliases, which essentially allow installing preact/compat
at node_modules/react
.
Here's how this example repo was set up:
- Set up a basic Next.js app using
create-next-app
- Install
preact
, uninstallreact
andreact-dom
. - Install preact-compat/react and preact-compat/react-dom for aliasing.
- Use an npm alias to replace
react-ssr-prepass
withpreact-ssr-prepass
(also works with Yarn).