Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/andrelmlins/svelte-device-detector

Render views on different device types
https://github.com/andrelmlins/svelte-device-detector

browser detector device os svelte

Last synced: about 5 hours ago
JSON representation

Render views on different device types

Awesome Lists containing this project

README

        

# Svelte Device Detector

[![npm version](https://badge.fury.io/js/svelte-device-detector.svg)](https://www.npmjs.com/package/svelte-device-detector) • [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/andrelmlins/svelte-device-detector/blob/master/LICENSE) • [![Build Status](https://travis-ci.com/andrelmlins/svelte-device-detector.svg?branch=master)](https://travis-ci.com/andrelmlins/svelte-device-detector)

Render views on different device types.

## Installation

```
npm i svelte-device-detector
// OR
yarn add svelte-device-detector
```

Note: to use this library in sapper, install as devDependency. See the [link](https://github.com/sveltejs/sapper-template#using-external-components).

## Demo

Local demo:

```
git clone https://github.com/andrelmlins/svelte-device-detector.git
cd svelte-device-detector
npm install && npm run dev
```

## Examples

An example of how to use the library:

```js

import DeviceDetector from "svelte-device-detector";

Desktop

Mobile and Chrome

Safari or Firefox

```

## Properties

For best results the values have these characteristics:

- Ignores sensitive case
- Ignore special character
- Removing accents
- Skips space

| Prop | Default | Type | Description |
| ------------- | ------- | ----------------- | --------------------------------------- |
| showInDevice | - | `string`, `array` | Render view on device types |
| showInBrowser | - | `string`, `array` | Render view on browser types |
| showInOs | - | `string`, `array` | Render view on operational system types |

## NPM Statistics

Download stats for this NPM package

[![NPM](https://nodei.co/npm/svelte-device-detector.png)](https://nodei.co/npm/svelte-device-detector/)

## License

Svelte Device Detector is open source software [licensed as MIT](https://github.com/andrelmlins/svelte-device-detector/blob/master/LICENSE).