Skip to content

Simple package to pipe sync and async props in next.js pages

Notifications You must be signed in to change notification settings

GuiBibeau/next-pipe-props

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Next pipe props

NPM
Next-pipe-props is a zero dependency package meant to give a pipe helper when getting ssr or static props to a Next.js page.

Installation

Simply install with yarn

yarn add next-pipe-props

or npm

npm install next-pipe-props --save

Usage:

next-pipe-props lets you pipe different functions (async works as well) in order to construct your final prop object. The data is piped from the first function and passed down as the argument to the next function. The best developer experience comes from passing full objects and returning your final prop object. the

import { pipeProps } from 'next-pipe-props';

function About({ helloWorld }) {
  return <div>{helloWorld}</div>;
}

export default About;

export const getStaticProps = pipeProps(
  async () => {
    return { initialData: 'hello' };
  },
  ({ initialData }) => {
    return { helloWorld: initialData + ' world' };
  }
);

About

Simple package to pipe sync and async props in next.js pages

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published