A lightweight fetch wrapper for Next.js that transparently passes cookies and CSRF tokens between server-side and client-side requests. Version 1.0.1 is the latest stable release. Unlike raw unfetch or isomorphic-fetch, it integrates req/res objects from Next.js context to maintain session consistency during SSR. Requires manual server-side configuration to copy set-cookie headers. No active development since 2018.
npm install next-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to use next-fetch in Next.js getInitialProps with req/res context.
Consider using native fetch or axios with manual cookie forwarding.
Add middleware to copy res.getHeader('set-cookie') to res.header('custom-set-cookie', ...).Migrate to getServerSideProps and handle cookies via req.headers.cookie.
Example: getFetch({ csrftokenHeaderName: 'x-csrf-token' }).const fetch = require('next-fetch')();Always pass req and res as third and fourth arguments: fetch(url, options, req, res).
Run: npm install next-fetch