0.15.8 • Published 4 months ago

@rethinkid/rethinkid-js-sdk v0.15.8

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

The RethinkID JavaScript SDK

A JavaScript SDK client for building SPAs (Single Page Apps) with RethinkID.

Using via NPM

Install with NPM:

npm i @rethinkid/rethinkid-js-sdk

Import the package:

import { RethinkID } from "@rethinkid/rethinkid-js-sdk";

const rid = new RethinkID({
  /* config... */
});

Load from a CDN

<script src="https://unpkg.com/@rethinkid/rethinkid-js-sdk"></script>

Next.js Caveats

Dynamic Imports

Next.js builds in a Node runtime by default. If components consuming the SDK are built for the server, it will result in build errors for missing browser-only items, like localStorage, document, window, and location. To resolve these errors dynamically import relevant components:

const MyComponent = dynamic(() => import("@/app/MyComponent"), {
  ssr: false,
});

Module Resolution Warnings

bufferutil and utf-8-validate cause module resolution warnings when building a Next.js app that uses the SDK. The warnings don't cause build errors but are very noisy and confusing. The warnings occur because socket.io-client is dependent on engine.io-client, which is dependent on ws, which has optional bufferutil and utf-8-validate peer dependencies. Something to do with the Next.js Webpack build triggers the warnings.

I attempted many other solutions, including adding a browser field to the SDK package.json file to ignore the offending packages and modifying rollup.config.js (ignoring the packages with the Rollup commonjs plugin, the replace plugin, and creating shims with the plugin-alias plugin.)

The warnings could resolved at the level of the app consuming the SDK with the following:

// next.config.js
const nextConfig = {
  webpack: (config) => {
    config.resolve.alias = {
      ...config.resolve.alias,
      bufferutil: false,
      "utf-8-validate": false,
    };
    return config;
  },
};
0.15.6

4 months ago

0.15.7

4 months ago

0.15.8

4 months ago

0.15.4

4 months ago

0.15.5

4 months ago

0.15.1

5 months ago

0.15.2

5 months ago

0.15.3

5 months ago

0.12.0

10 months ago

0.13.0

8 months ago

0.12.1

9 months ago

0.14.0

7 months ago

0.13.1

8 months ago

0.12.2

9 months ago

0.15.0

5 months ago

0.14.1

6 months ago

0.13.2

7 months ago

0.12.3

9 months ago

0.14.2

6 months ago

0.14.3

6 months ago

0.14.4

5 months ago

0.11.0

12 months ago

0.10.3

1 year ago

0.10.4

1 year ago

0.10.5

1 year ago

0.10.2

1 year ago

0.10.1

1 year ago

0.10.0

1 year ago