Skip to content

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.

License

Notifications You must be signed in to change notification settings

ezekielchentnik/preact-no-ssr

Repository files navigation

<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

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published