There are times that you will need to use a library that is purely client side in Sapper and some of these libraries make use of client side properties that are not available on the server. i.e. document

When you have hit such a case, its time to employ dynamic import. Here is an example below of how to make use of this.

export default {
  async oncreate() {
    const { default: SomeLibrary } = await import('some-library')
    this.someLib = new SomeLibrary(this.refs.thing)

That is all you would need in order to load up your library dynamically and since we are doing this in the oncreate, this will only every happen on the client side.