How to Get User Agent in Angular?

By Hardik Savani | December 23, 2019 | Category : Angular

Today, i would like to show you how to get user agent in angular application. we can simply get user agent in angular 8 application. we can get system user agent using window.navigator.

we can easily get user agent in angular 6, angular 7, angular 8, angular 9, angular 10 and angular 11 application.

Sometime, we need to get user agent value for storing information to our server. so if you want to get user agent value then you can use jquery code variable like window. using window function we can get user agent value in angular application.

You can see bellow full example step by step.

You can see component file code for getting user agent value in angular app.

Component File Code

import { Component, OnInit } from '@angular/core';


selector: 'app-blog',

templateUrl: './blog.component.html',

styleUrls: ['./blog.component.css']


export class BlogComponent implements OnInit {

constructor() { }

ngOnInit() {

const userAgent = window.navigator.userAgent;





Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36

I hope it can help you...

Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: