nest-next-spa
TypeScript icon, indicating that this package has built-in type declarations

0.0.36 • Public • Published

Next-Next-SPA

nest-next-spa provide states from nest-next via SPA mode. it exposes server parameters from nest controller method to next application, catched in getInitialProps

Installation

yarn add nest-next-spa

# or

npm install nest-next-spa

Usage

// app.module.ts
import { NestNextSpaModule } from 'nest-next-spa/server';
import { AppController } from './AppController';
import { Module } from '@nestjs/common';
import Next from 'next';
import { RenderModule } from 'nest-next';

@Module({
  controllers: [AppController],
  imports: [
    RenderModule.forRootAsync(
      Next({
        dev: process.env.NODE_ENV !== 'production',
      }),
      { passthrough404: true, viewsDir: null },
    ),
    NestNextSpaModule
  ],
})
export class AppModule {}

// app.controller.ts
import { Page } from 'nest-next-spa/server';

@Controller()
export class AppController {
	@Page('index')
	public index() {
		return {
			title: 'Hello World!',
		}
	}
}
// _app.tsx
import { INestNextApp, getNestNextInitialProps } from 'nest-next-spa';

const App: INestNextApp = ({ Component, pageProps }) => {
  return (
    <Component pageProps={pageProps} />
  );
};

App.getInitialProps = getNestNextInitialProps(() => ({
  description: 'my description'
}))

Readme

Keywords

none

Package Sidebar

Install

npm i nest-next-spa

Weekly Downloads

1

Version

0.0.36

License

ISC

Unpacked Size

11.4 kB

Total Files

23

Last publish

Collaborators

  • javeoff