Persisting a value

Advice required.

It has dawned on me that the env variables aren’t writeable from my netlify function, and as a newb in this area, I was wondering what my options are for saving a value from a function for use in the same function at a later time.

Are there any key/value services that anyone can recommend. Probably need to save 2 values so doesn’t need to be anything fancy. Performance and scale aren’t going to be an issue.

Or is there something else I can use / do?

You might want to look at using Fauna as they have a Netlify integration.

I know nothing more about this so can’t guide you, but that’s certainly an option if you wanted to do your best to keep it all “in” Netlify.

1 Like

Fauna is a great suggestion and would also have been mine. You could of course call a function which could write to any service including ones that require authentication; you’ll want to do this since most services require an auth token to be used in the request and on a fully static website…that token is in a format your visitors could discover and that’s bad. Here’s a code pattern to make a request like that:

I also believe that firebase may have write-only methods that are “static safe” as far as exposing the token.

Thanks, seems like Fauna will do fine. (Am currently struggling to use it due to a module initialization error but that’s a problem for another day)

Yes, anything I’m doing with this will be via a function to protect any tokens. Not to mention the values I’m storing themselves are secrets. (For my Strava account)

Thanks for the suggestions.