Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nest-next-renderer

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nest-next-renderer

Render Next.js pages in Nest.js applications

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Nest Next Renderer

npm version npm downloads/month GitHub license

Module for rendering Next.js pages inside Next.js applications.

Note: At the moment this package works only with Next and Fastify.

Installation

This package requires to be installed in a Next application that is using Fastify as platform (read more).

Peer dependencies

This is the full list of peer dependencies:

  • Nest: yarn add @nestjs/common
  • Fastify: yarn add fastify
  • Next, React and ReactDOM: yarn add react react-dom next

Note: In theory you should install just react, react-dom and next because @nestjs/common and fastify might be already installed.

Note: If you are using TypeScript, you should install @types/react and @types/react-dom as well.

Install

Run: yarn add nest-next-renderer

Usage

Import the module:

import { Module } from '@nestjs/common';
import { NextRendererModule } from 'nest-next-renderer';

@Module({
  imports: [
    NextRendererModule.forRoot({
      dev: process.env.NODE_ENV !== 'production',
      dir: './client',
      customServer: true,
      conf: {
        // Next.js config
      },
    }),
  ],
})
export class AppModule {}

Render from a controller:

// WIP

Contributing

You can contribute to this project by opening an issue or creating a pull request.

Note: If you want to test this library locally by using yarn link, you should know that there will be a conflict between the local @nestjs/common and @nestjs/core packages (devDependencies) and the ones in the test project. To fix this, you'll have to use the same module path in both projects.

TODO(s)

  • Add tests

  • Add documentation and example

  • Document the default values for the NextRendererModuleOptions

  • Add @Render decorator

  • Make it work with Express or others

  • Make it possible to render any page without a controller (useFileSystemPublicRoutes + @Get('*') and @Post('*') that calls next.handle)

  • Generate enum for the view parameter based on the content of the pages folder

  • Server not working with hot reload (if it's on the consumer side document the proper configuration)

  • Add a filter for errors and let the consumer choose how does he want to handle them (with Nest or with Next) (example)

  • Add command to copy the dist folder to a project that linked to this package for development purposes

    Example:

    1. Create a GIT ignored file called `linked-projects.paths` in the root of this project containing the paths to the projects that are linked to this package
    2. Create a script in the `package.json` file that copies the `dist` folder to the paths specified in the `linked-projects.paths` file
    3. Run the script after every build
    

Keywords

FAQs

Package last updated on 02 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc