Skip to content

Commit

Permalink
Only add to window if window exists (#42)
Browse files Browse the repository at this point in the history
This prevents `window is not defined` error when using SSR frameworks such as Next.js.
  • Loading branch information
SamSamskies authored Nov 23, 2020
1 parent 435b333 commit 5649df6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@
* new Suggestions(input, data);
*/
var Suggestions = require('./src/suggestions');
window.Suggestions = module.exports = Suggestions;
module.exports = Suggestions;

if (typeof window !== 'undefined') {
window.Suggestions = Suggestions;
}

0 comments on commit 5649df6

Please sign in to comment.