Nuxt/examples/dynamic-layouts/middleware/mobile.js
2018-08-08 12:54:05 +02:00

5 lines
159 B
JavaScript

export default function (ctx) {
const userAgent = ctx.req ? ctx.req.headers['user-agent'] : navigator.userAgent
ctx.isMobile = /mobile/i.test(userAgent)
}