userAgent is undefined
Unanswered
American black bear posted this in #help-forum
American black bearOP
I was checking the documentation and saw that next.js provides a userAgent function that returns a device.type.
I just did this and
I just did this and
device.type is returning undefined... shoud I do something specific?2 Replies
American black bearOP
code:
import {type NextRequest, NextResponse, userAgent} from 'next/server';
export function middleware(request: NextRequest) {
const {device} = userAgent(request);
console.log('deviceType', device.type);
...American black bearOP
actually, only type is undefined...
{
"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
"browser": {
"name": "Chrome",
"version": "129.0.0.0",
"major": "129"
},
"engine": {
"name": "Blink",
"version": "129.0.0.0"
},
"os": {
"name": "Mac OS",
"version": "10.15.7"
},
"device": {
"vendor": "Apple",
"model": "Macintosh",
"type": "undefined"
},
"cpu": {
"architecture": "undefined"
},
"isBot": false
}