nuxt-lifecycle
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

📦 Nuxt-Lifecycle

A life cycle hook that runs before rendering or routing occurs in Nuxt.


🌎 Global

The following multilingual documents are provided. (need pull request help)

(한국어 문서 보기)


⚗️ Installation

Please enter the command below to install this module.

npm i nuxt-lifecycle

Then define the following in nuxt.config.js or nuxt.config.ts.

{
  "modules": ["nuxt-lifecycle"]
}

🔮 How to use

Instructions on how to use the nuxt-life cycle module are described below.

import * as Lifecycle from 'nuxt-lifecycle'
 
Lifecycle.onPrefetch(async (url, context) => {
  // Runs before rendering or routing occurs on clients and servers.
  // (If Promise is returned, rendering or routing will
  //  not occur until the processing is complete.)
})
 
Lifecycle.onServerPrefetch(async (url, context) => {
  // Runs before rendering or routing occurs on the server.
  // (If Promise is returned, rendering or routing will
  //  not occur until the processing is complete.)
})
 
Lifecycle.onClientPrefetch(async (url, context) => {
  // Runs before rendering or routing occurs on the client.
  // (If Promise is returned, rendering or routing will
  //  not occur until the processing is complete.)
})
 
// Returns true if it is currently operating on a client.
Lifecycle.isClient()
 
// Returns true if it is currently operating on a server.
Lifecycle.isServer()

🏷 License

MIT Licensed.

Package Sidebar

Install

npm i nuxt-lifecycle

Weekly Downloads

6

Version

1.0.3

License

MIT

Unpacked Size

21.5 kB

Total Files

24

Last publish

Collaborators

  • hm-lee