<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Dapr Configuration JavaScript SDK on Dapr Docs</title><link>https://docs.dapr.io/developing-applications/sdks/js/js-configuration/</link><description>Recent content in Dapr Configuration JavaScript SDK on Dapr Docs</description><generator>Hugo</generator><language>en</language><atom:link href="https://docs.dapr.io/developing-applications/sdks/js/js-configuration/index.xml" rel="self" type="application/rss+xml"/><item><title>How to: Manage configuration with the Dapr JavaScript SDK</title><link>https://docs.dapr.io/developing-applications/sdks/js/js-configuration/js-configuration-howto/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://docs.dapr.io/developing-applications/sdks/js/js-configuration/js-configuration-howto/</guid><description>&lt;p>Use &lt;code>DaprClient.configuration&lt;/code> to read application settings and react to changes without calling the configuration store directly. This guide uses Redis for local development.&lt;/p>
&lt;h2 id="prerequisites">Prerequisites&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://docs.dapr.io/getting-started/install-dapr-cli/">Dapr CLI&lt;/a> and an initialized &lt;a href="https://docs.dapr.io/getting-started/install-dapr-selfhost/">Dapr environment&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://nodejs.org/">Node.js&lt;/a> 18 or later&lt;/li>
&lt;li>The &lt;a href="https://www.npmjs.com/package/@dapr/dapr">&lt;code>@dapr/dapr&lt;/code>&lt;/a> package, version 3.19.0 or later&lt;/li>
&lt;li>Docker, for the Redis example below&lt;/li>
&lt;/ul>
&lt;p>In your application directory, initialize an npm project if needed and install the SDK:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sh" data-lang="sh">&lt;span class="line">&lt;span class="cl">npm init -y
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">npm install @dapr/dapr@3.19.0
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The examples use JavaScript ES modules saved as &lt;code>.mjs&lt;/code> files and do not require a TypeScript compiler. The same APIs are available in TypeScript.&lt;/p></description></item><item><title>Configuration client usage</title><link>https://docs.dapr.io/developing-applications/sdks/js/js-configuration/js-configuration-client-usage/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://docs.dapr.io/developing-applications/sdks/js/js-configuration/js-configuration-client-usage/</guid><description>&lt;p>Configuration is available through &lt;code>DaprClient.configuration&lt;/code>. This guide targets &lt;code>@dapr/dapr&lt;/code> 3.19.0 or later and describes the implementation details and limitations to account for when using this release.&lt;/p>
&lt;h2 id="client-lifetime-and-configuration">Client lifetime and configuration&lt;/h2>
&lt;p>Reuse a long-lived &lt;code>DaprClient&lt;/code> for configuration operations rather than creating one for each read or subscription. Configuration requires gRPC; the SDK&amp;rsquo;s default protocol is HTTP and is not supported for these methods.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-javascript" data-lang="javascript">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">import&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">CommunicationProtocolEnum&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">DaprClient&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="nx">from&lt;/span> &lt;span class="s2">&amp;#34;@dapr/dapr&amp;#34;&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">const&lt;/span> &lt;span class="nx">client&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="k">new&lt;/span> &lt;span class="nx">DaprClient&lt;/span>&lt;span class="p">({&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">daprHost&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s2">&amp;#34;127.0.0.1&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">daprPort&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="nx">process&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">env&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">DAPR_GRPC_PORT&lt;/span> &lt;span class="o">??&lt;/span> &lt;span class="s2">&amp;#34;50001&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">communicationProtocol&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="nx">CommunicationProtocolEnum&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">GRPC&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Port values are strings. When you omit explicit host and port options, the SDK can resolve the sidecar address from &lt;code>DAPR_GRPC_ENDPOINT&lt;/code>. Otherwise, it falls back to the configured host and port, with defaults of &lt;code>127.0.0.1&lt;/code> and &lt;code>DAPR_GRPC_PORT&lt;/code> (or &lt;code>50001&lt;/code>). Explicit host and port options take precedence over endpoint settings.&lt;/p></description></item></channel></rss>