How can run a function before render template in nuxt

Viewed 1347

As mentioned in documents, everything in nuxt is between two options server side or client side. What if you need to run a function in client side, exactly before rendering templates.

My specific use case is user device detection in nuxt static mode. If you use ssr mode its easy to find just by {req} object but in static before find the device and applying on conditional classes, html and Dom are rendered in advanced.

1 Answers

So You're using SPA mode?

Following Nuxt lifecycle - Nuxt client lifecycle

You can attach detection like this on a middleware or in some created/beforeMount hook.

Related