0

I have React.js project that needs to convert to a Next.js

This project has a file data-pulse-provider.js

import { logMessage, } from './helpers';
import $ from 'jquery';


require('signalr');
window.jQuery = $;

var DataPulseProvider = /** @class */ (function () {
 //...
}());
export { DataPulseProvider };

Here I am getting an error

Error: jQuery was not found. Please ensure jQuery is referenced before the SignalR client JavaScript file.

I think this window object is not available all the time in next.js. The solution I found was use dynamic imports with SSR false and then use useEffect to window object-related code. But this is a pure js file hence I can't use the useEffect or something like that. So how can I fix this issue?

Any help! Thanks in advance.

margherita pizza
  • 6,623
  • 23
  • 84
  • 152

0 Answers0