@finastra/ssr-pages
TypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published

SSR Pages builder

Builder of html pages for the purpose of SSR (Server-side rendering).

Use it

import { SSRPages } from '@finastra/ssr-pages';

const ssrPagesService = new SSRPages();
const msgPageOpts = {
  title: 'SSR example',
  subtitle: `This is an example of a server-side rendered content`,
  description: 'Built with @finastra/ssr-pages library',
  svg: 'exit' as const,
  redirect: {
    auto: false,
    link: '/user',
    label: 'Check your user',
  },
};
const html = ssrPagesService.build(msgPageOpts);

And use the generated html as you see fit ;)




NestJS

To use it in NestJS, simply create an injectable service that extends the SSRPage class.

import { SSRPages } from '@finastra/ssr-pages';
import { Injectable } from '@nestjs/common';

@Injectable()
export class SSRPagesService extends SSRPages {
  constructor() {
    super();
  }
}

Inject it in a controller, and use it in an endpoint to return the templated html !

constructor(private ssrPagesService: SSRPagesService) {}

@Get('/ssr')
  async ssr(): Promise<string> {
    const msgPageOpts = {
      title: 'SSR example',
      subtitle: `This is an example of a server-side rendered content`,
      description: 'Built with our @finastra/ssr-pages library',
      svg: 'exit' as const,
      redirect: {
        auto: false,
        link: '/user',
        label: 'Check your user',
      },
    };
    return this.ssrPagesService.build(msgPageOpts);
  }

Readme

Keywords

none

Package Sidebar

Install

npm i @finastra/ssr-pages

Weekly Downloads

15

Version

0.1.6

License

MIT

Unpacked Size

3.31 MB

Total Files

39

Last publish

Collaborators

  • david.bocle
  • ffdcbot
  • ttalbot