1.0.1 • Published 5 years ago

@mustafarefaey/laravel-hybrid-spa-page-state-loader v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

This package is meant to be used in conjunction with Laravel hybrid SPA. It provides the functionality to load page state.

Installation

npm install @mustafarefaey/laravel-hybrid-spa-page-state-loader

Usage

import { loadPageState } from '@mustafarefaey/laravel-hybrid-spa-page-state-loader';

After creating an instance of Vue router, add this navigation guard

router.beforeEach(async (to, from, next) => {
  const pageStateLoaded = await loadPageState(
    '__PAGE_STATE__',
    to.fullPath,
    (err) => console.error(err)
  );

  if (pageStateLoaded) {
    next();
  } else {
    next(false);
  }
});