Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/exortek/remix-fastify
Fastify server request handler for Remix
https://github.com/exortek/remix-fastify
fastify fastify-plugin remix
Last synced: about 2 months ago
JSON representation
Fastify server request handler for Remix
- Host: GitHub
- URL: https://github.com/exortek/remix-fastify
- Owner: ExorTek
- License: mit
- Created: 2024-09-29T20:46:05.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-10-02T10:34:27.000Z (3 months ago)
- Last Synced: 2024-10-11T14:23:48.097Z (2 months ago)
- Topics: fastify, fastify-plugin, remix
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@exortek/remix-fastify
- Size: 956 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @exortek/remix-fastify
Fastify plugin for Remix.
### Compatibility
| Plugin version | Fastify version |
|----------------|:---------------:|
| `^1.x` | `^5.x` |## Installation
```bash
npm install @exortek/remix-fastify
```OR
```bash
yarn add @exortek/remix-fastify
```## Usage
CommonJS:
```javascript
const fastify = require('fastify');
const remixFastify = require("@exortek/remix-fastify");const app = fastify();
app.register(remixFastify({
buildDirectory: 'build', // default
clientDirectory: 'client', // default
serverDirectory: 'server', // default
serverBuildFile: 'index.js', // default
mode: process.env.NODE_ENV || 'development', // default
fastifyStaticOptions: {}, // default
viteOptions: {}, // default
}));app.listen({port: 3000, host: 'localhost'}, (err, address) => {
if (err) {
console.error(err);
}
console.log(`Server listening at ${address}`);
});
```ESM:
```javascript
import fastify from 'fastify';
import remixFastify from "@exortek/remix-fastify";const app = fastify();
app.register(remixFastify({
buildDirectory: 'build', // default
clientDirectory: 'client', // default
serverDirectory: 'server', // default
serverBuildFile: 'index.js', // default
mode: process.env.NODE_ENV || 'development', // default
fastifyStaticOptions: {}, // default
viteOptions: {}, // default
}));app.listen({port: 3000, host: 'localhost'}, (err, address) => {
if (err) {
console.error(err);
}
console.log(`Server listening at ${address}`);
});
```
## How to use in ProjectSet up your project as per the [Remix documentation](https://remix.run/docs/en/main/other-api/create-remix). Then,
follow the steps below:1. Create a new file in the root of your project called `server.mjs`.
2. Add the following code to the file:```javascript
import fastify from 'fastify';
import remixFastify from "@exortek/remix-fastify";const app = fastify();
app.register(remixFastify({
buildDirectory: 'build', // default
clientDirectory: 'client', // default
serverDirectory: 'server', // default
serverBuildFile: 'index.js', // default
mode: process.env.NODE_ENV || 'development', // default
fastifyStaticOptions: {}, // default
viteOptions: {}, // default
}));app.listen({port: 3000, host: 'localhost'}, (err, address) => {
if (err) {
console.error(err);
}
console.log(`Server listening at ${address}`);
});
```3. Add the following script to your `package.json`:
```json
{
"scripts": {
"dev": "cross-env NODE_ENV=development node server.mjs",
"start": "cross-env NODE_ENV=production node server.mjs"
}
}
```4. Run the following command to start the server:
```bash
npm run dev
npm run start
```OR
```bash
yarn dev
yarn start
```## License
**[MIT](https://github.com/ExorTek/remix-fastify/blob/master/LICENSE)**