next-combine
v1.0.1
Published
Package of utility functions for generating server-side Next.js functions
Downloads
0
Readme
next-combine
next-combine is a micro-library that allows fast creation of middleware-like functions that are composed into a single Next.js 'get' function
Prerequisites
Next.js 12
Installation
npm install next-combineUsage
next-combine allows you to return additional properties from each handler. Those properties are:
notFound: boolean- behaves exactly like it's Next.js counterpart but also halts the execution of the next functionsredirect: Redirect- behaves exactly like it's Next.js counterpart but also halts the execution of the next functionsbreak: boolean- halts the execution of the next functions
getServerSideProps
import { composeServerSideProps } from "next-combine";
export const getServerSideProps = composeServerSideProps(
async (ctx) => {
return { props: { hello: "world" }, break: true };
},
async (ctx) => {
return { props: { hello: "github" } };
}
);will return { props: { hello: 'world' } }
