1.0.1 • Published 2 years ago
next-combine v1.0.1
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-combine
Usage
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' } }