Skip to main content

Device

A Device is a service that provides us with device information.

Import

import {Device} from 'frontik/device'

Basic Usage

import {Device} from 'frontik/device'

console.log(Device.width); // 1920
console.log(Device.height); // 1080

API


Device.width

import {Device} from 'frontik/device'

console.log(Device.width); // 1920

Returns <number>

Returns the interior width of the window in pixels. This includes the width of the vertical scroll bar, if one is present.


Device.height

import {Device} from 'frontik/device'

console.log(Device.height); // 1080

Returns <number>

Returns the interior height of the window in pixels. This includes the height of the horizontal scroll bar, if one is present.


Device.browserName

import {Device} from 'frontik/device'

console.log(Device.browserName); // Google Chrome

List of browsers

  • Google Chrome
  • Safari
  • Firefox
  • Internet Explorer
  • Microsoft Edge
  • Opera

Returns <string>

Returns the browser name.


Device.isChrome

import {Device} from 'frontik/device'

console.log(Device.isChrome); // true

Returns <boolean>

Returns true if the browser is Google Chrome, false otherwise.


Device.isSafari

import {Device} from 'frontik/device'

console.log(Device.isSafari); // false

Returns <boolean>

Returns true if the browser is Safari, false otherwise.


Device.isFirefox

import {Device} from 'frontik/device'

console.log(Device.isFirefox); // false

Returns <boolean>

Returns true if the browser is Firefox, false otherwise.


Device.isIE

import {Device} from 'frontik/device'

console.log(Device.isIE); // false

Returns <boolean>

Returns true if the browser is Internet Explorer, false otherwise.


Device.isEdge

import {Device} from 'frontik/device'

console.log(Device.isEdge); // false

Returns <boolean>

Returns true if the browser is Microsoft Edge, false otherwise.


Device.isOpera

import {Device} from 'frontik/device'

console.log(Device.isOpera); // false

Returns <boolean>

Returns true if the browser is Opera, false otherwise.


React

See: useDevice hook