DEV Community

Cover image for Mantainig Session in Nuxt JS Laravel Authentication API
Kelvin Chidothi
Kelvin Chidothi

Posted on

Mantainig Session in Nuxt JS Laravel Authentication API

l had an issue in my recent project. Well based on the title, you guessed right "Mantaining session". As much as NuxtJS provides a proper configuration of API integrations and ofcourse authentication with **@nuxt/next-auth** package, it's somehow challenging to keep session.

In my project l was using Laravel as the backend framework and created API's guarded with sactum. After configuring everything as per (https://auth.nuxtjs.org/schemes/local). It was really hard. *Session was being removed on reload page of the nuxtjs app.
*

So here was a work around to it. I added vuex-persist package to the nuxt project using yarn and created a plugin. l added the plugin in the plugins sections in nuxt.config.js and automatically my data was saved in a cookie as much as session was active!

l hope you guys read more about vuex-persist or other related libraries. If any questions let me know.
đź‘Śđź‘Ś

Top comments (0)