@waku/sdk package is primarily designed for browser environments, you can use it in a NodeJS application. However, there are certain limitations and considerations to keep in mind. This guide provides a comprehensive overview of using
@waku/sdk in NodeJS.
@waku/sdk prioritises browser compatibility, avoiding NodeJS APIs for simpler bundling. This design choice enhances browser API compatibility but sacrifices NodeJS optimisation. While many browser APIs work in NodeJS, they might need better optimisation.
@waku/sdk aims to provide optimal default for the browser, striking a balance between browser and NodeJS compatibility while ensuring simplicity will add complexity.
Certain features in
@waku/sdk are tailored for browsers and might not translate seamlessly to NodeJS. For example, only
WebSocket is supported in the browser, whereas a NodeJS application can benefit from using transport methods like
@waku/sdk default peer management caters to the browser's ephemeral nature, which is different for NodeJS. This is why DNS Discovery and Peer Exchange are the default discovery mechanisms for the browser but not for NodeJS and desktop applications.
There are plans to release a NodeJS package based on nwaku to streamline the process of using Waku Network features in NodeJS applications. You can track the progress and updates here: https://github.com/waku-org/nwaku/issues/1332.