<titledata-rh="true">Run @waku/sdk in a NodeJS Application | Waku Documentation</title><metadata-rh="true"name="viewport"content="width=device-width,initial-scale=1"><metadata-rh="true"name="twitter:card"content="summary_large_image"><metadata-rh="true"property="og:url"content="https://docs.waku.org/build/javascript/run-waku-nodejs"><metadata-rh="true"property="og:locale"content="en_GB"><metadata-rh="true"name="docusaurus_locale"content="en-GB"><metadata-rh="true"name="docsearch:language"content="en-GB"><metadata-rh="true"name="keywords"content="waku, web3"><metadata-rh="true"name="image"content="https://docs.waku.org/_og/3695c886b1d8a696215f7d58e19b24e7b0784e25.png"><metadata-rh="true"name="docusaurus_version"content="current"><metadata-rh="true"name="docusaurus_tag"content="docs-default-current"><metadata-rh="true"name="docsearch:version"content="current"><metadata-rh="true"name="docsearch:docusaurus_tag"content="docs-default-current"><metadata-rh="true"property="og:title"content="Run @waku/sdk in a NodeJS Application | Waku Documentation"><metadata-rh="true"name="description"content="While the @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."><metadata-rh="true"property="og:description"content="While the @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."><linkdata-rh="true"rel="icon"href="/theme/image/favicon.ico"><linkdata-rh="true"rel="canonical"href="https://docs.waku.org/build/javascript/run-waku-nodejs"><linkdata-rh="true"rel="alternate"href="https://docs.waku.org/build/javascript/run-waku-nodejs"hreflang="en-GB"><linkdata-rh="true"rel="alternate"href="https://docs.waku.org/build/javascript/run-waku-nodejs"hreflang="x-default"><linkrel="alternate icon"type="image/png"href="/theme/image/favicon.png">
<h2class="anchor anchorWithHideOnScrollNavbar_WYt5"id="limitations">Limitations<ahref="#limitations"class="hash-link"aria-label="Direct link to Limitations"title="Direct link to Limitations"></a></h2>
<h3class="anchor anchorWithHideOnScrollNavbar_WYt5"id="api-compatibility">API compatibility<ahref="#api-compatibility"class="hash-link"aria-label="Direct link to API compatibility"title="Direct link to API compatibility"></a></h3>
<p><code>@waku/sdk</code> 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.</p>
<h3class="anchor anchorWithHideOnScrollNavbar_WYt5"id="protocol-implementation">Protocol implementation<ahref="#protocol-implementation"class="hash-link"aria-label="Direct link to Protocol implementation"title="Direct link to Protocol implementation"></a></h3>
<p><code>@waku/sdk</code> focuses on the client side of the <ahref="/learn/concepts/network-domains#requestresponse-domain">Request/Response protocol</a>. We'll have to replicate all the functionalities added to <ahref="/run-node/">nwaku</a> to implement extra features.</p>
<h3class="anchor anchorWithHideOnScrollNavbar_WYt5"id="codebase-complexity">Codebase complexity<ahref="#codebase-complexity"class="hash-link"aria-label="Direct link to Codebase complexity"title="Direct link to Codebase complexity"></a></h3>
<p><code>@waku/sdk</code> aims to provide optimal default for the browser, striking a balance between browser and NodeJS compatibility while ensuring simplicity will add complexity.</p>
<h3class="anchor anchorWithHideOnScrollNavbar_WYt5"id="browser-specific-protocols">Browser-specific protocols<ahref="#browser-specific-protocols"class="hash-link"aria-label="Direct link to Browser-specific protocols"title="Direct link to Browser-specific protocols"></a></h3>
<p>Certain features in <code>@waku/sdk</code> are tailored for browsers and might not translate seamlessly to NodeJS. For example, only <code>WebSocket</code> is supported in the browser, whereas a NodeJS application can benefit from using <ahref="/learn/concepts/transports">transport methods</a> like <code>TCP</code>.</p>
<p><code>@waku/sdk</code> default peer management caters to the browser's ephemeral nature, which is different for NodeJS. This is why <ahref="/learn/concepts/dns-discovery">DNS Discovery</a> and <ahref="/learn/concepts/peer-exchange">Peer Exchange</a> are the default discovery mechanisms for the browser but not for NodeJS and desktop applications.</p>
<h2class="anchor anchorWithHideOnScrollNavbar_WYt5"id="recommendations">Recommendations<ahref="#recommendations"class="hash-link"aria-label="Direct link to Recommendations"title="Direct link to Recommendations"></a></h2>
<p>Before using <code>@waku/sdk</code> in a NodeJS environment, take into account these limitations. For a more optimised solution, we recommend <ahref="/run-node/run-docker-compose">running nwaku in a Docker container</a> and consuming its <ahref="https://waku-org.github.io/waku-rest-api/"target="_blank"rel="noopener noreferrer">REST API</a>.</p>
<h2class="anchor anchorWithHideOnScrollNavbar_WYt5"id="future-developments">Future developments<ahref="#future-developments"class="hash-link"aria-label="Direct link to Future developments"title="Direct link to Future developments"></a></h2>