New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-instantsearch-nextjs

Package Overview
Dependencies
Maintainers
4
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-instantsearch-nextjs - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

38

dist/cjs/InstantSearchNext.js

@@ -30,16 +30,2 @@ "use strict";

var isServer = typeof window === 'undefined';
var hasRouteChanged = (0, _react.useMemo)(function () {
// On server, always return false
if (isServer) {
return false;
}
// On client, route has changed if initialResults have been cleaned up
var hasInitialResults = window[InstantSearchInitialResults] !== undefined;
return !hasInitialResults;
}, [isServer]);
// We only want to trigger a search from a server environment
// or if a Next.js route change has happened on the client
var shouldTriggerSearch = isServer || hasRouteChanged;
(0, _react.useEffect)(function () {

@@ -61,2 +47,14 @@ isMounting.current = false;

var routing = (0, _useInstantSearchRouting.useInstantSearchRouting)(passedRouting, isMounting);
process.env.NODE_ENV === 'development' ? (0, _warn.warn)(false, "InstantSearchNext relies on experimental APIs and may break in the future.\nThis message will only be displayed in development mode.") : void 0;
return /*#__PURE__*/_react.default.createElement(ServerOrHydrationProvider, {
isServer: isServer
}, /*#__PURE__*/_react.default.createElement(_reactInstantsearchCore.InstantSearch, _extends({}, instantSearchProps, {
routing: routing
}), isServer && /*#__PURE__*/_react.default.createElement(_InitializePromise.InitializePromise, {
nonce: nonce
}), children, isServer && _ref2));
}
function ServerOrHydrationProvider(_ref3) {
var isServer = _ref3.isServer,
children = _ref3.children;
var promiseRef = (0, _react.useRef)(null);

@@ -66,3 +64,7 @@ var initialResults = (0, _utils.safelyRunOnBrowser)(function () {

});
process.env.NODE_ENV === 'development' ? (0, _warn.warn)(false, "InstantSearchNext relies on experimental APIs and may break in the future.\nThis message will only be displayed in development mode.") : void 0;
// If we're not on the server and we don't need to hydrate, we don't need SSR context
if (!isServer && !initialResults) {
return children;
}
return /*#__PURE__*/_react.default.createElement(_reactInstantsearchCore.InstantSearchRSCContext.Provider, {

@@ -72,7 +74,3 @@ value: promiseRef

initialResults: initialResults
}, /*#__PURE__*/_react.default.createElement(_reactInstantsearchCore.InstantSearch, _extends({}, instantSearchProps, {
routing: routing
}), shouldTriggerSearch && /*#__PURE__*/_react.default.createElement(_InitializePromise.InitializePromise, {
nonce: nonce
}), children, shouldTriggerSearch && _ref2)));
}, children));
}

@@ -6,3 +6,3 @@ var _excluded = ["children", "routing"];

import { safelyRunOnBrowser } from "instantsearch.js/es/lib/utils/index.js";
import React, { useEffect, useMemo, useRef } from 'react';
import React, { useEffect, useRef } from 'react';
import { InstantSearch, InstantSearchRSCContext, InstantSearchSSRProvider } from 'react-instantsearch-core';

@@ -22,16 +22,2 @@ import { InitializePromise } from "./InitializePromise.js";

var isServer = typeof window === 'undefined';
var hasRouteChanged = useMemo(function () {
// On server, always return false
if (isServer) {
return false;
}
// On client, route has changed if initialResults have been cleaned up
var hasInitialResults = window[InstantSearchInitialResults] !== undefined;
return !hasInitialResults;
}, [isServer]);
// We only want to trigger a search from a server environment
// or if a Next.js route change has happened on the client
var shouldTriggerSearch = isServer || hasRouteChanged;
useEffect(function () {

@@ -53,2 +39,14 @@ isMounting.current = false;

var routing = useInstantSearchRouting(passedRouting, isMounting);
process.env.NODE_ENV === 'development' ? warn(false, "InstantSearchNext relies on experimental APIs and may break in the future.\nThis message will only be displayed in development mode.") : void 0;
return /*#__PURE__*/React.createElement(ServerOrHydrationProvider, {
isServer: isServer
}, /*#__PURE__*/React.createElement(InstantSearch, _extends({}, instantSearchProps, {
routing: routing
}), isServer && /*#__PURE__*/React.createElement(InitializePromise, {
nonce: nonce
}), children, isServer && _ref2));
}
function ServerOrHydrationProvider(_ref3) {
var isServer = _ref3.isServer,
children = _ref3.children;
var promiseRef = useRef(null);

@@ -58,3 +56,7 @@ var initialResults = safelyRunOnBrowser(function () {

});
process.env.NODE_ENV === 'development' ? warn(false, "InstantSearchNext relies on experimental APIs and may break in the future.\nThis message will only be displayed in development mode.") : void 0;
// If we're not on the server and we don't need to hydrate, we don't need SSR context
if (!isServer && !initialResults) {
return children;
}
return /*#__PURE__*/React.createElement(InstantSearchRSCContext.Provider, {

@@ -64,7 +66,3 @@ value: promiseRef

initialResults: initialResults
}, /*#__PURE__*/React.createElement(InstantSearch, _extends({}, instantSearchProps, {
routing: routing
}), shouldTriggerSearch && /*#__PURE__*/React.createElement(InitializePromise, {
nonce: nonce
}), children, shouldTriggerSearch && _ref2)));
}, children));
}
{
"name": "react-instantsearch-nextjs",
"version": "0.4.1",
"version": "0.4.2",
"description": "React InstantSearch SSR utilities for Next.js",

@@ -52,5 +52,5 @@ "types": "dist/es/index.d.ts",

"devDependencies": {
"instantsearch.js": "4.77.0",
"instantsearch.js": "4.77.1",
"next": "15.1.4",
"react-instantsearch-core": "7.15.0"
"react-instantsearch-core": "7.15.1"
},

@@ -61,3 +61,3 @@ "peerDependencies": {

},
"gitHead": "d3e46fedc5bba4482cfc5aadaf9b9c436681e93f"
"gitHead": "3d0c6cbcb894a0b38a81485bc98de6244b70b97e"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc