# fastify-nuxtjs

> Vue server side rendering support for Fastify with Nuxt

Latest version **1.0.1** (published 2021-01-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install fastify-nuxtjs
pnpm add fastify-nuxtjs
yarn add fastify-nuxtjs
bun add fastify-nuxtjs
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-01-28 |
| First published | 2021-01-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 1 |
| Unpacked size | 15.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 40 |
| Author | Thomas Marrec - @Gomah |
| Maintainers | gomah |
| Keywords | fastify, vue, nuxt, ssr, server, side, rendering |

## Links

- npm: https://www.npmjs.com/package/fastify-nuxtjs
- Repository: https://github.com/gomah/fastify-nuxtjs
- Homepage: https://github.com/gomah/fastify-nuxtjs#readme
- Issues: https://github.com/gomah/fastify-nuxtjs/issues
- npm.io page: https://npm.io/package/fastify-nuxtjs

## Dependencies (1)

- [fastify-plugin](https://npm.io/package/fastify-plugin.md) ^3.0.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-01-28
- 1.0.0 — 2021-01-28

## README

# fastify-nuxtjs

[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) ![CI workflow](https://github.com/gomah/fastify-nuxtjs/workflows/CI%20workflow/badge.svg)

Vue server side rendering support for Fastify with [Nuxt.js](https://nuxtjs.org/docs/2.x/internals-glossary/nuxt) Framework.

## Install

```
npm i fastify-nuxtjs nuxt --save
```

## Usage

Since Nuxt needs some time to be ready on the first launch, you must declare your routes inside the `after` callback, after you registered the plugin.
The plugin will expose the api `nuxt` in Fastify that will handle the rendering for you.

```js
const fastify = require('fastify')();

fastify.register(require('fastify-nuxtjs')).after(() => {
  fastify.nuxt('/hello');
});

fastify.listen(3000, err => {
  if (err) throw err;
  console.log('Server listening on http://localhost:3000');
});
```

All you server rendered pages must be saved in the folder `pages`, as you can see in the [nuxt documentation](https://nuxtjs.org/docs/2.x/internals-glossary/nuxt).

```vue
<template>
  <HelloWorld />
</template>
```

If you need to handle the render part yourself, just pass a callback to `nuxt`:

```js
fastify.nuxt('/hello', (app, req, reply) => {
  // your code
  // `app` is the Nuxt instance
  app.render(req.raw, reply.raw, '/hello', req.query, {});
});
```

## Acknowledgements

Heavily inspired by [fastify-nextjs](https://github.com/fastify/fastify-nextjs)

## License

Licensed under [MIT](./LICENSE).

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