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: 3 months ago
JSON representation
Render views on different device types
- Host: GitHub
- URL: https://github.com/andrelmlins/svelte-device-detector
- Owner: andrelmlins
- License: mit
- Created: 2020-05-29T03:56:13.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-19T04:11:05.000Z (almost 2 years ago)
- Last Synced: 2025-03-28T23:51:11.915Z (3 months ago)
- Topics: browser, detector, device, os, svelte
- Language: JavaScript
- Size: 391 KB
- Stars: 19
- Watchers: 1
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Svelte Device Detector
[](https://www.npmjs.com/package/svelte-device-detector) • [](https://github.com/andrelmlins/svelte-device-detector/blob/master/LICENSE) • [](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
[](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).