All Projects → scaleapi → Data Prefetch Link

scaleapi / Data Prefetch Link

Licence: mit
Extends next.js <Link> to allow invoking getInitialProps when prefetching a page

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Data Prefetch Link

Nextjs Headless Wordpress
🔥 Nextjs Headless WordPress
Stars: ✭ 110 (-14.06%)
Mutual labels:  nextjs
Next Redux Wrapper
Redux wrapper for Next.js
Stars: ✭ 1,901 (+1385.16%)
Mutual labels:  nextjs
Nextjs Pwa Graphql Sql Boilerplate
Next.js serverless PWA with GraphQL (Apollo) + Postgres SQL boilerplate
Stars: ✭ 125 (-2.34%)
Mutual labels:  nextjs
Frontend Computer Science
A list of Computer Science topics important for a Front-End Developer to learn 📝
Stars: ✭ 113 (-11.72%)
Mutual labels:  caching
Next Todos
200 lines realtime todos app powered by next.js, preact, jet, redux and now
Stars: ✭ 117 (-8.59%)
Mutual labels:  nextjs
Next Optimized Images
🌅 next-optimized-images automatically optimizes images used in next.js projects (jpeg, png, svg, webp and gif).
Stars: ✭ 1,870 (+1360.94%)
Mutual labels:  nextjs
Wagtail Pipit
Pipit is a Wagtail CMS boilerplate which aims to provide an easy and modern developer workflow with a React-rendered frontend.
Stars: ✭ 109 (-14.84%)
Mutual labels:  nextjs
Pathpida
TypeScript friendly internal link client for Next.js, Nuxt.js and Sapper.
Stars: ✭ 127 (-0.78%)
Mutual labels:  nextjs
Mdx Embed
Embed 3rd party media content in MDX - no import required 🧽
Stars: ✭ 119 (-7.03%)
Mutual labels:  nextjs
Next Page Tester
DOM integration testing for Next.js
Stars: ✭ 122 (-4.69%)
Mutual labels:  nextjs
Next Sanity
Sanity.io toolkit for Next.js
Stars: ✭ 115 (-10.16%)
Mutual labels:  nextjs
Create Ueno App
The easiest and fastest way to create new web projects with next, gatsby, create-react-app and mobile projects with react-native.
Stars: ✭ 116 (-9.37%)
Mutual labels:  nextjs
Gank
🦅 Gank api base △ next.js (react&ssr)
Stars: ✭ 122 (-4.69%)
Mutual labels:  nextjs
Amazon Next
A simple mock and re-concept of Amazon - built with Next.js, Firebase, and Framer Motion
Stars: ✭ 112 (-12.5%)
Mutual labels:  nextjs
Css In Js
A thorough analysis of all the current CSS-in-JS solutions with SSR & TypeScript support for Next.js
Stars: ✭ 127 (-0.78%)
Mutual labels:  nextjs
Next Cms Ghost
Publish flaring fast blogs with Next.js and Ghost CMS
Stars: ✭ 107 (-16.41%)
Mutual labels:  nextjs
Cash
HTTP response caching for Koa. Supports Redis, in-memory store, and more!
Stars: ✭ 122 (-4.69%)
Mutual labels:  caching
Giraffeql
🦒 Developer tool to visualize relational databases and export schemas for GraphQL API's.
Stars: ✭ 128 (+0%)
Mutual labels:  nextjs
Relay Example
[READONLY] 💝 Examples of common Relay patterns used in real-world applications. This repository is automatically exported from https://github.com/adeira/universe via Shipit
Stars: ✭ 126 (-1.56%)
Mutual labels:  nextjs
Hazelcast Nodejs Client
Hazelcast IMDG Node.js Client
Stars: ✭ 124 (-3.12%)
Mutual labels:  caching

data-prefetch-link

Extends <Link> to allow invoking getInitialProps when prefetching a page. That way, if you use a caching layer in getInitialProps, the page data will be already cached when you click the link, thus producing the same instantaneous navigation that is possible with prefetched static pages.

This approach is explained in more detail in our blog post: Increasing the Performance of Dynamic Next.js Websites.

Installation

npm i --save data-prefetch-link

Usage

This component extends Next.js <Link>, so you can use the same parameters and expect the same behavior. Additionally, you can pass the prop withData, which will make it run getInitialProps when prefetching (this only works when prefetch is also used). So a usage with data prefetching would look like this:

import Link from 'data-prefetch-link'

<Link prefetch withData href="…"><a>Some dynamic page</a></Link>

When getInitialProps is invoked by this component, the context will receive an isVirtualCall flag set to true, which can be used to skip fetching resources that will not be cached, so these calls are not made unnecessarily.

Note

Prefetching data should be used strategically, rather than habitually.

A good use case might be high-level pages in the header navigation, in which there are typically only a handful. Or when you'd expect a link to get clicked on.

You probably wouldn't want to use it on large lists of links (e.g. grid with infinite scroll) as this would negatively affect performance — for both your users and the web server that's handling the requests.

Licence

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].