|
| 1 | +--- |
| 2 | +title:Useragent |
| 3 | +description:Wrapper around the User-Agent Client Hints API. |
| 4 | +--- |
| 5 | + |
| 6 | +<script> |
| 7 | +importMetafrom"$components/meta.svelte" |
| 8 | +</script> |
| 9 | + |
| 10 | +<Meta /> |
| 11 | + |
| 12 | +Wrapper around the[User-Agent Client Hints API.](https://developer.mozilla.org/en-US/docs/Web/API/User-Agent_Client_Hints_API) |
| 13 | +##Usage |
| 14 | + |
| 15 | +```svelte |
| 16 | +<script> |
| 17 | + import {useragent} from "@sveu/browser" |
| 18 | +
|
| 19 | + const { |
| 20 | + supported, |
| 21 | + mobile, |
| 22 | + arch, |
| 23 | + model, |
| 24 | + platform, |
| 25 | + platformVersion, |
| 26 | + bitness, |
| 27 | + brands |
| 28 | + } = useragent() |
| 29 | +</script> |
| 30 | +``` |
| 31 | + |
| 32 | +##Example |
| 33 | + |
| 34 | +```svelte live ln |
| 35 | +<script> |
| 36 | +import { useragent } from "@sveu/browser" |
| 37 | +
|
| 38 | + const { |
| 39 | + supported, |
| 40 | + mobile, |
| 41 | + arch, |
| 42 | + model, |
| 43 | + platform, |
| 44 | + platformVersion, |
| 45 | + bitness, |
| 46 | + brands |
| 47 | + } = useragent() |
| 48 | +</script> |
| 49 | +
|
| 50 | +<div class="text-center"> |
| 51 | + <h1>Supported: <small>{$supported}</small></h1> |
| 52 | +
|
| 53 | + <h1>Is mobile: <small>{$mobile}</small></h1> |
| 54 | +
|
| 55 | + <h1>Architecture: <small>{$arch}</small></h1> |
| 56 | +
|
| 57 | + <h1>Model: <small>{$model}</small></h1> |
| 58 | +
|
| 59 | + <h1>Platform: <small>{$platform}</small></h1> |
| 60 | +
|
| 61 | + <h1>Platform version: <small>{$platformVersion}</small></h1> |
| 62 | +
|
| 63 | + <h1>Bitness: <small>{$bitness}</small></h1> |
| 64 | +
|
| 65 | + <h1>Brands: <small>{JSON.stringify($brands)}</small></h1> |
| 66 | +</div> |
| 67 | +``` |
| 68 | + |
| 69 | +##API |
| 70 | + |
| 71 | +###Returns |
| 72 | + |
| 73 | +| Name| Description| Type| |
| 74 | +| -----------| -------------------------------------------------------------| ----------------| |
| 75 | +|**supported**| Whether the browser supports the User-Agent Client Hints api.| Readable<`boolean`>| |
| 76 | +|**mobile**| Whether the device is a mobile device.| Readable<`boolean`>| |
| 77 | +|**arch**| The architecture of the device.| Readable<`string`>| |
| 78 | +|**model**| The model of the device.| Readable<`string`>| |
| 79 | +|**platform**| The platform of the device.| Readable<`string`>| |
| 80 | +|**platformVersion**| The platform version of the device.| Readable<`string`>| |
| 81 | +|**bitness**| The bitness of the device.| Readable<`string`>| |
| 82 | +|**brands**| The brands of the device.| Readable<`UserAgentDataBrand`[]>| |