From 17c44396f70bbb98d1b1fcaf708bcba52968ff6b Mon Sep 17 00:00:00 2001 From: Sam Miyakawa Date: Sun, 6 Sep 2020 15:40:42 -0700 Subject: [PATCH] Only add to window if window exists This prevents `window is not defined` error when using SSR frameworks such as Next.js. --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e949417..070a38c 100644 --- a/index.js +++ b/index.js @@ -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; +}