You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sessions are used to store user state between requests for server-rendered pages, such as login status, shopping cart contents, or other user-specific data.
8
+
9
+
```astro
10
+
---
11
+
export const prerender = false; // Not needed in 'server' mode
Sessions are available in on-demand rendered/SSR pages, API endpoints, actions and middleware. To enable session support, you must configure a storage driver.
19
+
20
+
If you are using the Node.js adapter, you can use the `fs` driver to store session data on the filesystem:
21
+
22
+
```js
23
+
// astro.config.mjs
24
+
{
25
+
adapter:node({ mode:'standalone' }),
26
+
experimental: {
27
+
session: {
28
+
// Required: the name of the Unstorage driver
29
+
driver:"fs",
30
+
},
31
+
},
32
+
}
33
+
```
34
+
If you are deploying to a serverless environment, you can use drivers such as `redis` or `netlifyBlobs` or `cloudflareKV` and optionally pass additional configuration options.
35
+
36
+
For more information, including using the session API with other adapters and a full list of supported drivers, see [the docs for experimental session support](https://docs.astro.build/en/reference/experimental-flags/sessions/). For even more details, and to leave feedback and participate in the development of this feature, [the Sessions RFC](https://github.com/withastro/roadmap/pull/1055).
0 commit comments