/preact-no-ssr

A Preact component for skipping server side rendering (SSR) of components. This component helps render components on the server that make sense to be rendered above the fold or that only makes sense to render on client.

Primary LanguageJavaScriptMIT LicenseMIT

<NoSir /> for Preact

NPM Travis

A Preact component for skipping server side rendering (SSR) of components. This component helps render components on the server that make sense to be rendered above the fold or that only makes sense to render on client. Depending on your server side render, this can significantly boost performance.


Usage Example

Install

npm i preact-no-ssr --save

Wrap the components you do not want to render on server when using 'preact-render-to-string'

import NoSsr from 'preact-no-ssr';

<NoSsr
  placeholder={<MySpinnerOrPlaceholder />} // placeholder to render on server, defaults to null
  skip={false} // toggle on/off server render, defaults to true
>
  <div>Stuff to not render on server</div>
</NoSsr>

Props

Prop Type Description
placeholder Function Component to render on server
skip Boolean If false, renders on server

License

MIT