UNPKG

react-instantsearch-nextjs

Version:
19 lines 876 B
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } import { headers } from "next/headers.js"; import { use } from 'react'; function isPromise(obj) { return obj && (_typeof(obj) === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; } export var useNextHeaders = function useNextHeaders() { var isServer = typeof window === 'undefined'; var h; if (isServer) { var nextHeaders = headers(); if (isPromise(headers())) { h = use(nextHeaders); } else { h = nextHeaders; // assert that headers come from the synchronous nextjs function } } return h; };