You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP β†’

@midudev/react-progressive-hydration

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@midudev/react-progressive-hydration

Server Side Rendering for a component and skip the hydration step on the client but, as soon as it appears on the viewport, then hydrate it. Useful for list of items.

2.0.2
latest
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created

Progressive Hydration 🏁

Server Side Rendering for a component and skip the hydration step on the client but, as soon as it appears on the viewport, hydrate it. Useful for list of items or components that are not visible on the viewport but yet you need to render them for SEO.

Results of using it

Benefits... πŸ‘

  • πŸ‘€ Only re-hydrate what's visible
  • 🀳 Thus could greatly improve TTI
  • πŸ”› Activate interactivity on demand

Downsides... πŸ‘Ž

  • πŸ‹οΈβ€ Hydration data still there
  • πŸ₯ͺ Element wrapper needed (ex. <div>)

Keep in mind... 🧠

  • πŸ“Έ Kind of lazy loading experience
  • πŸ€– GoogleBot will get the rendered static html (not hydrated)

How to use πŸ‘¨β€πŸ«

Just wrap the components you want to be hydrated progressively.

Use force prop in order to hydrate the component no matter if it's below the fold.

import ProgressiveHydration from '@midudev/react-progressive-hydration'

export default function ProgressiveHydrationPage({articles}) {
  return (
    <Grid>
      {articles.map((article, idx) => (
        <ProgressiveHydration key={idx} force={idx < 3}>
          <Card {...article} />
        </ProgressiveHydration>
      ))}
    </Grid>
  )
}

Resources πŸ”—

The case of partial hydration (with Next and Preact) Rendering on the Web: Performance Implications of Application Architecture Hack for avoiding hydration

FAQs

Package last updated on 29 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts