question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage with Nuxt3 (SSR)

See original GitHub issue

Hello! Thanks for great package. My problem:

  1. Nuxt 3, vue 3, pinia 2.0
  2. Create plugin, code:
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
import {NuxtApp} from 'nuxt3';

export default function ({$pinia, ssrContext}: NuxtApp) {
  $pinia.use(piniaPluginPersistedstate);
}
  1. Then I create build (ssr enabled) and then start server, I get this error:
extender is not a function
  at file://./server/node_modules/pinia/dist/pinia.mjs:1556:43
  1. This block of code in pinia.mjs:
// apply all plugins
pinia._p.forEach((extender) => {
  assign(store, scope.run(() => extender({
      store,
      app: pinia._a,
      pinia,
      options: optionsForPlugin,
  })));
})

How should i use package correctly with nuxt3 ssr?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
prazdevscommented, Feb 10, 2022

Ok here’s a working store definition using Nuxt’s useCookie:

import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', {
  state: () => ({
    token: 'fake'
  }),
  persist: {
    storage: {
      getItem: (key) => { return useCookie(key, { encode: x => x, decode: x => x }).value },
      setItem: (key, value) => { useCookie(key, { encode: x => x, decode: x => x }).value = value },
      removeItem: (key) => { useCookie(key, { encode: x => x, decode: x => x }).value = null },
    }
  },
})
1reaction
prazdevscommented, Jan 6, 2022

Hi, thanks for using it! I haven’t looked much into Nuxt 3 yet, I was waiting for it to go out of beta, but I’ll try to have a look at it when I have some time. I’ll try at least to reproduce it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server Side Rendering - Nuxt
Server-side rendering (SSR), is the ability of an application to contribute by displaying the web-page on the server instead of rendering it in...
Read more >
How To Use Server-Side Rendering with Nuxt.js | DigitalOcean
With Nuxt, all of your routes are generated from .vue files in the pages directory. Inside of these pages you can fetch data...
Read more >
How To Create A Nuxt 3 Vue.js App With SSR In Seconds!
Transcript · Why Use Nuxt JS 3 Beta?! (Vue.js 3 With Nuxt Tutorial!!) · Create A Website In VSCode In Less Then A...
Read more >
Creating Server-side Rendered Vue.js Apps Using Nuxt.js
Nuxt.js is based off an implementation of SSR for the popular React library ... To start off, let's use a Vue project generator...
Read more >
Rendering Modes in Nuxt 3 - This Dot Labs
To deploy and use our Nuxt 3 application on a node-server in universal mode: First in nuxt.config.js file. defineNuxtConfig({ ssr: true ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found