> For the complete documentation index, see [llms.txt](https://docs.balena.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.balena.io/reference/sdk/node-sdk/latest/setsharedoptions.md).

# SetSharedOptions

`module:balena-sdk~setSharedOptions(options)`

Set options that are used by calls to `fromSharedOptions()`. The options accepted are the same as those used in the main SDK factory function. If you use this method, it should be called as soon as possible during app startup and before any calls to `fromSharedOptions()` are made.

**Kind**: inner function\
**Summary**: Set shared default options\
**Access**: public

| Param                               | Type                    | Default                               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ----------------------------------- | ----------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| options                             | `Object`                |                                       | The shared default options                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| \[options.apiUrl]                   | `String`                | `'https://api.balena-cloud.com/'`     | the balena API url to use.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| \[options.builderUrl]               | `String`                | `'https://builder.balena-cloud.com/'` | the balena builder url to use.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| \[options.deviceUrlsBase]           | `String`                | `'balena-devices.com'`                | the base balena device API url to use.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| \[options.requestLimit]             | `Number`                |                                       | the number of requests per requestLimitInterval that the SDK should respect.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| \[options.requestLimitInterval]     | `Number`                | `60000`                               | the timespan that the requestLimit should apply to in milliseconds, defaults to 60000 (1 minute).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| \[options.retryRateLimitedRequests] | `Boolean` \| `function` | `false`                               | <p>Determines whether to automatically retry requests that are failing with a 429 Too Many Requests status code and that include a numeric Retry-After response header.</p><ul><li>If <code>false</code>, rate-limited requests will not be retried, and the rate limit error will be propagated.</li><li>If <code>true</code>, all rate-limited requests will be retried after the duration specified by the <code>Retry-After</code> header.</li><li>If a function <code>(retryAfterMs: number) => boolean</code> is provided, it will be called with the retry duration in ms and the request will be retried only when <code>true</code> is returned.</li></ul> |
| \[options.dataDirectory]            | `String` \| `False`     | `'$HOME/.balena'`                     | *ignored in the browser unless false*, the directory where the user settings are stored, normally retrieved like `require('balena-settings-client').get('dataDirectory')`. Providing `false` creates an isolated in-memory instance.                                                                                                                                                                                                                                                                                                                                                                                                                                |
| \[options.isBrowser]                | `Boolean`               |                                       | the flag to tell if the module works in the browser. If not set will be computed based on the presence of the global `window` value.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| \[options.debug]                    | `Boolean`               |                                       | when set will print some extra debug information.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

**Example**

```js
import { setSharedOptions } from 'balena-sdk';
setSharedOptions({
	apiUrl: 'https://api.balena-cloud.com/',
	builderUrl: 'https://builder.balena-cloud.com/',
	isBrowser: true,
});
```

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.balena.io/reference/sdk/node-sdk/latest/setsharedoptions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
