Skip to content

Commit

Permalink
Added info about SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandstedt committed Oct 25, 2020
1 parent 419a9fc commit 93a7e8e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/tutorials/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,8 @@ spinner.play();"
Go creative!

See the [API](/api/README.md) for more info.

## Usage with Server Side Rendering (SSR)
Note that this is a client-side library, and is not meant to be run on a server. So if you are using a library like Next.js, Gatsby, Nuxt.js or Angular Universal, make sure not to run your MoJS code on the server, just on the client side. How to do that differs from the library you are using. In React based libraries you can use the `useEffect` hook or a dynamic import ([read more here](https://dev.to/vvo/how-to-solve-window-is-not-defined-errors-in-react-and-next-js-5f97)). For Angular Universal you can use Guards ([read more about it here](https://github.com/angular/universal/blob/master/docs/gotchas.md#window-is-not-defined)). Lastly if you use Vue with Nuxt.js, you will find [more info here](https://nuxtjs.org/faq/window-document-undefined), or info about using the `mounted` hook [here](https://nuxtjs.org/guides/concepts/server-side-rendering).

Also see tutorial on how to use MoJS inside a [React app here](./usage-with-react.md).
6 changes: 5 additions & 1 deletion docs/tutorials/usage-with-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,4 +343,8 @@ ReactDOM.render(
You can see the full example and try it out here: [CodeSandbox](https://codesandbox.io/s/mojs-react-example-kbikb?file=/src/MojsExample.js).
There is also a [button example](https://codesandbox.io/s/mojs-react-example-kbikb?file=/src/Button.js) with a `Burst` animation using an object pooling array.

Happy animating!_
::: tip Usage with Server Side Rendering (SSR)
Note that MoJS is a client-side library, and is not meant to be run on a server. So if you are using a library like Next.js or Gatsby, make sure not to run your MoJS code on the server, just on the client side. You can do this by using the `useEffect` hook like we did above, or using a dynamic import ([read more here](https://dev.to/vvo/how-to-solve-window-is-not-defined-errors-in-react-and-next-js-5f97)).
:::

Happy animating!

0 comments on commit 93a7e8e

Please sign in to comment.