Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.
This repository was archived by the owner on Dec 12, 2023. It is now read-only.

Session are not available on server side rendering #57

Closed
@leo91000

Description

@leo91000

Environment

Nuxt project info:                                                                                                                                                                                                                                                               19:11:34

------------------------------
- Operating System: `Windows_NT`
- Node Version:     `v16.17.0`
- Nuxt Version:     `3.0.0`
- Nitro Version:    `1.0.0`
- Package Manager:  `pnpm@7.24.3`
- Builder:          `vite`
- User Config:      `srcDir`, `telemetry`, `css`, `modules`, `app`, `runtimeConfig`, `vite`, `session`
- Runtime Modules:  `@groufr/muffins-nuxt@0.1.0`, `@pinia/nuxt@0.4.6`, `@sidebase/nuxt-session@0.2.6`
- Build Modules:    `-`
------------------------------

Reproduction

<script setup>
const { session, update } = await useSession()

const value = ref('')
watch(session, (s) => {
    console.log('session value :', s)
    if (s.value)
        value.value = s.value
}, { immediate: true })
watch(value, async (value) => {
    await update({ value })
})
</script>

<template>
    <input v-model="value" />
</template>

https://stackblitz.com/edit/github-e43zzb?file=app.vue

If you type something in the input and refresh the page, the server will not know about the session that was updated, thus preventing doing server side rendering without node mismatch.

Describe the bug

I'd like to access my sessions in my root app.vue file :

If I run this code, it works well on client side. However on server side the value of the session is always empty.
Can I access the data on server side so I can do proper server side rendering ?

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions