Node.js - secret.version()
This is reference documentation for the Nitric Node.js SDK. To learn about Secrets in Nitric start with the Secrets docs.
Returns a reference to a known version of a secret.
import { secret } from '@nitric/sdk'const keyRef = secret('encryptionKey').allow('access')const keyVersionRef = keyRef.version('the-version-id')
Parameters
- Name
version
- Required
- Required
- Type
- string
- Description
The version ID. This value is returned from secret.put().
Examples
Return a reference to a known secret version
import { secret } from '@nitric/sdk'const keyRef = secret('encryptionKey').allow('access')const keyVersionRef = keyRef.version('the-version-id')
Access the value of a known secret version
import { secret } from '@nitric/sdk'const keyRef = secret('encryptionKey').allow('access')const keyValue = await keyRef.version('the-version-id').access()keyValue.asString()
See also
Last updated on Apr 3, 2025