Skip to main content
Version: 3.3.2


The SecretStore constructor lets you connect your Fastly Compute application to a Fastly Secret store.

A secret store is a persistent, globally distributed store for secrets accessible to Fastly Compute services during request processing.

Note: Can only be used when processing requests, not during build-time initialization.


new SecretStore(name)

Note: SecretStore() can only be constructed with new. Attempting to call it without new throws a TypeError.


  • name : string
    • The Fastly Secret Store which should be associated with this SecretStore instance

Return value

A new SecretStore object.


  • TypeError
    • Thrown if no Secret Store exists with the provided name
    • Thrown if the provided name is longer than 255 in length
    • Thrown if the provided name is an empty string
    • Thrown if the provided name contains characters other than letters, numbers, dashes (-), underscores (_), and periods (.)


In this example we connect to a Secret Store named 'secrets' and retrieve a secret named 'cat-api-key' use the value in a Request header.

/// <reference types="@fastly/js-compute" />

import { SecretStore } from "fastly:secret-store";

async function app(event) {
const secrets = new SecretStore('secrets')

const catApiKey = await secrets.get('cat-api-key')

return fetch('/api/cat', {
headers: {
'cat-api-key': catApiKey.plaintext()

addEventListener("fetch", (event) => event.respondWith(app(event)))