Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

next-useragent

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-useragent

next-useragent parses browser user-agent strings for next.js.

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

next-useragent

next-useragent parses browser user-agent strings for next.js.

npm

Installation

$ npm install next-useragent

Usage

next-useragent is simple to use.
First parse a string with parse and then access the fields of UserAgent for the required information.

Example usage:

import React from 'react'
import { UserAgentType, parse } from 'next-useragent'

interface Props {
  ua: UserAgentType
}

export default class IndexPage extends React.Component<Props> {

  static async getInitialProps(ctx) {
    const ua = parse(ctx)

    return { ua }
  }

  render() {
    const { ua } = this.props

    return (
      <ul>
        <li>{ ua.source }</li>
        <li>{ ua.device }</li>
        <li>{ ua.deviceVersion }</li>
        <li>{ ua.os }</li>
        <li>{ ua.osVersion }</li>
        <li>{ ua.browser }</li>
        <li>{ ua.browserVersion }</li>
      </ul>
    )
  }
}

License

next-useragent is licensed under MIT License.
See LICENSE for more information.

Keywords

FAQs

Package last updated on 10 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc