diff --git a/docs/docs/using-client-side-only-packages.md b/docs/docs/using-client-side-only-packages.md new file mode 100644 index 0000000000000..464c918b3483d --- /dev/null +++ b/docs/docs/using-client-side-only-packages.md @@ -0,0 +1,85 @@ +--- +title: Using Client-Side Only Packages +--- + +On occasion, you may need to use a function or library that only works client side. This usually is because the library in question accesses something that isn't available during server-side rendering (SSR), like [browser DOM](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model) methods. + +You'll need to use one of the workarounds outlined below if your project fails to compile with `gatsby develop` or `gatsby build` with an error like: + +```bash +Reference error: Window is not Defined +``` + +## Workaround 1: Use a different library or approach + +Sometimes the simplest approach is to work around the problem. If you can re-implement your component using a plugin which _doesn't_ break SSR, that's probably best. + +## Workaround 2: Add client-side package via CDN + +In the component where you need it, load the package via CDN using a [`