withastro / roadmap

Ideas, suggestions, and formal RFC proposals for the Astro project.
292 stars 29 forks source link

Simplified cookie management #275

Closed matthewp closed 1 year ago

matthewp commented 2 years ago

Summary

Provides a simpler API for getting and setting cookie values through a Map-like interface:

---
const prefs = Astro.cookies.get('prefs').json();
---
<body data-theme={prefs.darkMode ? 'dark' : 'light'}>

And setting:

---
Astro.cookies.set('prefs', { darkMode: true }, {
  expires: '1 month'
});
---

Links

natemoo-re commented 1 year ago

This was accepted on our community call!