DEV Community

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

Posted on

4 2

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.
👌👌

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs