# next-preactx

> Plugin to enable Preact@>10 to a next project

Latest version **1.0.1** (published 2020-04-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install next-preactx
pnpm add next-preactx
yarn add next-preactx
bun add next-preactx
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-04-30 |
| First published | 2020-04-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Matt Styles |
| Maintainers | mattstyles |
| Keywords | next, nextjs, preact, plugin |

## Links

- npm: https://www.npmjs.com/package/next-preactx
- Repository: https://github.com/mattstyles/next-preactx
- Homepage: https://github.com/mattstyles/next-preactx#readme
- Issues: https://github.com/mattstyles/next-preactx/issues
- npm.io page: https://npm.io/package/next-preactx

## Dependencies (1)

- [module-alias](https://npm.io/package/module-alias.md) 2.0.6

## Recent versions

- 1.0.1 (latest) — 2020-04-30
- 1.0.0 — 2020-04-30

## README

# Next and Preact X

There are a couple of original lines of code in here, almost all is repurposed from [the official next-preact package](https://github.com/zeit/next-plugins/tree/master/packages/next-preact) and Jason Millers [next-preact-demo](https://github.com/developit/nextjs-preact-demo/blob/master/next.config.js).

This plugin exists for 3 reasons:

* The official plugin is currently incompatible with the latest version of Preact (this has been fixed up, but is currently unreleased)
* Adds support for Preact devtools
* Adds a flag to allow an easier way to use Preact **only** in production.

If you aren’t interested in running React in dev and Preact in production then consider using npm aliases as it is by far the easiest solution (see [Jason Millers demo](https://github.com/developit/nextjs-preact-demo/blob/master/package.json).)

## Getting Started

```sh
npm i -D next-preactx
npm i -S preact
```

Add the plugin to your `next.config.js`:

```js
const withPreact = require('next-preactx')({
  enabled: process.env.NODE_ENV === 'production'
})

module.exports = withPreact({
  // Config options
})
```

To ensure that Preact also renders on the server you have to make sure you are setting up Preact aliases _before_ starting your service.

This can either be done by creating a custom server for next to use and requiring `next-preactx/alias` within that entry script (as shown in the [official plugin](https://github.com/zeit/next-plugins/tree/master/packages/next-preact)) or creating a custom javascript script to start the process:

```js
// start.js

require('next-preactx/alias')()
require('next/dist/bin/next')
```

## License

MIT

---
_Source: https://npm.io/package/next-preactx · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
