The documentation you are viewing is for Dapr v1.9 which is an older version of Dapr. For up-to-date documentation, see the latest version.

JetStream KV

Detailed information on the JetStream KV state store component

Component format

To setup a JetStream KV state store create a component of type state.jetstream. See this guide on how to create and apply a state store configuration.

kind: Component
  name: <NAME>
  type: state.jetstream
  version: v1
  - name: natsURL
    value: "nats://localhost:4222"
  - name: jwt
    value: "eyJhbGciOiJ...6yJV_adQssw5c" # Optional. Used for decentralized JWT authentication
  - name: seedKey
    value: "SUACS34K232O...5Z3POU7BNIL4Y" # Optional. Used for decentralized JWT authentication
  - name: bucket
    value: "<bucketName>"

Spec metadatafield

Field Required Details Example
natsURL Y NATS server address URL nats://localhost:4222
jwt N NATS decentralized authentication JWT eyJhbGciOiJ...6yJV_adQssw5c
seedKey N NATS decentralized authentication seed key SUACS34K232O...5Z3POU7BNIL4Y
bucket Y JetStream KV bucket name "<bucketName>"

Create a NATS server

You can run a NATS Server with JetStream enabled locally using Docker:

docker run -d -p 4222:4222 nats:latest -js

You can then interact with the server using the client port: localhost:4222.

Install NATS JetStream on Kubernetes by using the helm:

helm repo add nats
helm install my-nats nats/nats

This installs a single NATS server into the default namespace. To interact with NATS, find the service with: kubectl get svc my-nats.

Creating a JetStream KV bucket

It is necessary to create a key value bucket, this can easily done via NATS CLI.

nats kv add <bucketName>