Skip to main content
Official Plugin
View plugin on GitHub
See starters using this

gatsby-plugin-preact

Provides drop-in support for replacing React with Preact.

While Preact doesn’t provide full support for the React ecosystem, it is an intriguing option for Gatsby sites as it saves ~30kb of JavaScript vs. using React.

Note: This plugin uses Preact X, any version prior to v10.0.0 is incompatible with Gatsby v2.

Install

npm install --save gatsby-plugin-preact preact

How to use

// In your gatsby-config.js
plugins: [`gatsby-plugin-preact`]

Usage in a development environment

Gatsby development server currently has a hardcoded dependency on React-dom, therefore this plugin does not enable Preact in development.

While Preact is designed to be a drop-in replacement, you should check that your production build works as expected before putting it live.


Edit this page on GitHubLast updated: