@nexst/core
TypeScript icon, indicating that this package has built-in type declarations

0.0.62 • Public • Published

😎 @nexst/core 😎

NexstAppModule & NextModule

In the server/app.module.ts:

import {
  Module,
  MiddlewareConsumer,
} from '@nestjs/common';
import {
  NexstAppModule,
  NextModule,
} from '@nexst/core';
import { AppController } from './app.controller';

@Module({
  imports: [
    NextModule,
  ],
  controllers: [
    AppController,
  ],
})
export class AppModule extends NexstAppModule {
  configure(consumer: MiddlewareConsumer) {
    super.configure(consumer);

    // additional configurations here
  }
}

Then, use render() function where you want to SSR:

import {
  Controller,
  Get,
  Req,
  Res,
} from '@nestjs/common';
import {
  Request,
  Response,
} from 'express';
import { NextService } from '@nexst/core';

@Controller('auth')
export class AuthController {
  constructor(private readonly nextService: NextService) {}

  @Get('register')
  public async showRegisterPage(@Req() req: Request, @Res() res: Response) {
    return await this.nextService.render(req, res, 'auth/register');
  }
}

This will render pages/auth/register.tsx!

Package Sidebar

Install

npm i @nexst/core

Weekly Downloads

2

Version

0.0.62

License

MIT

Unpacked Size

60.3 kB

Total Files

65

Last publish

Collaborators

  • saltyshiomix