diff --git a/llms-full.txt b/llms-full.txt index 86326a5d..46cb381e 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -15592,6 +15592,29 @@ const client = new Client({ }); ``` +The token is optional. If you leave it out, the client reads `QSTASH_TOKEN`, +`QSTASH_URL` and their [region-prefixed variants](/docs/qstash/howto/multi-region) +from the environment, and only warns when it finds nothing: + +```typescript +const client = new Client(); +``` + +Use `Client.fromEnv()` if you would rather fail fast: + +```typescript +const client = Client.fromEnv(); +// throws: [Upstash QStash] Unable to find environment variable: QSTASH_TOKEN. +``` + + + `fromEnv` reads `process.env`, so on runtimes where credentials only exist as + bindings (Cloudflare Workers) pass the token to `new Client()` instead. + + +No credentials at all? You don't need any while developing — see +[Local development](#local-development) below. + #### RetryConfig You can configure the retry policy of the client by passing the configuration to the client constructor. diff --git a/qstash/sdks/ts/gettingstarted.mdx b/qstash/sdks/ts/gettingstarted.mdx index f0d4ffa1..adfbdc88 100644 --- a/qstash/sdks/ts/gettingstarted.mdx +++ b/qstash/sdks/ts/gettingstarted.mdx @@ -24,6 +24,29 @@ const client = new Client({ }); ``` +The token is optional. If you leave it out, the client reads `QSTASH_TOKEN`, +`QSTASH_URL` and their [region-prefixed variants](/qstash/howto/multi-region) +from the environment, and only warns when it finds nothing: + +```typescript +const client = new Client(); +``` + +Use `Client.fromEnv()` if you would rather fail fast: + +```typescript +const client = Client.fromEnv(); +// throws: [Upstash QStash] Unable to find environment variable: QSTASH_TOKEN. +``` + + + `fromEnv` reads `process.env`, so on runtimes where credentials only exist as + bindings (Cloudflare Workers) pass the token to `new Client()` instead. + + +No credentials at all? You don't need any while developing — see +[Local development](#local-development) below. + #### RetryConfig You can configure the retry policy of the client by passing the configuration to the client constructor.