# Secrets / environment variables

**URL:** https://talk.observablehq.com/t/secrets-environment-variables/916
**Category:** Help
**Created:** [June 24, 2018, 4:03pm UTC](https://talk.observablehq.com/t/secrets-environment-variables/916 "2018-06-24T16:03:35Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jflatow](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jflatow/32/3401_2.png) [@jflatow](https://talk.observablehq.com/u/jflatow)
#### Post date: [June 24, 2018, 4:03pm UTC](https://talk.observablehq.com/t/secrets-environment-variables/916/1 "2018-06-24T16:03:35Z")

</div>

Are there any plans for a way to include secrets (e.g. API keys) that are private to the user executing the notebook, even if the notebook itself is public? RunKit allows environment variables ([https://discuss.runkit.com/t/using-environment-variables-with-tonic/21](https://discuss.runkit.com/t/using-environment-variables-with-tonic/21)) which seems like a fairly elegant solution.

---

<div class="post-metadata">

### Author: ![jrus](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jrus/32/586_2.png) [@jrus](https://talk.observablehq.com/u/jrus)
#### Post date: [June 24, 2018, 6:43pm UTC](https://talk.observablehq.com/t/secrets-environment-variables/916/2 "2018-06-24T18:43:14Z")

</div>

Couldn’t that just be any cell? If someone types an API key into their local copy of a notebook, it doesn’t get published.

Alternately, you could make a little view which saves a variable typed into it to localStorage or whatever.

This feature doesn’t necessarily require any explicit support from Observable.

---

<div class="post-metadata">

### Author: ![tom](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tom/32/2262_2.png) [@tom](https://talk.observablehq.com/u/tom)
#### Post date: [June 24, 2018, 9:43pm UTC](https://talk.observablehq.com/t/secrets-environment-variables/916/3 "2018-06-24T21:43:32Z")

</div>

Yep, what Jacob said - and to make it concrete & reusable, here’s a notebook that you can import from and quickly start storing environment/secrets:

> **[Secret](https://observablehq.com/@tmcw/secret)**
>
> An Observable notebook by Tom MacWright.

---

<div class="post-metadata">

### Author: ![jrus](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jrus/32/586_2.png) [@jrus](https://talk.observablehq.com/u/jrus)
#### Post date: [June 24, 2018, 9:59pm UTC](https://talk.observablehq.com/t/secrets-environment-variables/916/4 "2018-06-24T21:59:32Z")

</div>

Not sure how much it matters, but note that if you want this to work in Safari or Edge you can’t use spread syntax in object literals.

So …

```
  const input = text({
    value,
    ...options
  });

```

… throws an error.

---

<div class="post-metadata">

### Author: ![jflatow](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jflatow/32/3401_2.png) [@jflatow](https://talk.observablehq.com/u/jflatow)
#### Post date: [June 24, 2018, 10:15pm UTC](https://talk.observablehq.com/t/secrets-environment-variables/916/5 "2018-06-24T22:15:34Z")

</div>

Wow, thanks for the thoughtful replies. I love the back and forth between questions \<\> notebooks. I’m not sure, but I think there might still be good reasons to want secrets in a place well-defined by the notebook runtime/environment. Need to play with this mechanism for a while now 🙂

---

<div class="post-metadata">

### Author: ![PotOfCoffee2Go](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/potofcoffee2go/32/1091_2.png) [@PotOfCoffee2Go](https://talk.observablehq.com/u/PotOfCoffee2Go)
#### Post date: [October 12, 2018, 9:21pm UTC](https://talk.observablehq.com/t/secrets-environment-variables/916/6 "2018-10-12T21:21:34Z")

</div>

Not to revive an old topic. But would be great if Tom’s Secret notebook was moved to one of the main observable collections - maybe `Techniques` ? Not that hard to find with google search - but didn’t know it existed - and between all my cloud services out there, got a lot of secrets in the closet : - is a great import if one knew it existed. @tom
