Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/pages/docs/hooks/_meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"useTranslation": "useTranslation",
"useMousePosition": "useMousePosition",
"useTimer": "useTimer"
"useTimer": "useTimer",
"useDetectDevice": "useDetectDevice"
}
53 changes: 53 additions & 0 deletions docs/pages/docs/hooks/useDetectDevice.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# useDetectDevice

## Introduce

현재 디바이스의 유형(moblie, desktop), OS 및 Browser를 감지합니다.

import { Callout } from 'nextra/components';

<Callout type="info">
userAgent의 업데이트로 인하여 올바르게 작동하지 않을 수 있습니다. 유의해서
사용해주세요.
</Callout>

```ts
interface UseDeviceDetectReturns {
isMobile: boolean;
isDesktop: boolean;
os: string;
browser: string;
}

const useDetectDevice = (): UseDeviceDetectReturns
```

### Returns

- `isMobile` : 사용 중인 디바이스의 Mobile 여부를 나타냅니다.
- `isDesktop` : 사용 중인 디바이스의 Desktop 여부를 나타냅니다.
- `os` : 사용 중인 디바이스의 OS 이름(문자열)을 나타냅니다.\
cf) Windows, macOS, Linux, Android, iOS
- `browser` : 사용 중인 브라우저의 이름(문자열)을 나타냅니다.\
cf) Chrome, Safari, Whale, Edge, Firefox

## Examples

```tsx copy filename="TestComponent.tsx"
const TestComponent = () => {

const { isMobile, os, browser } = useDeviceDetect();

return (
<div>
<div>
{isMobile && (
<>
<div>모바일 환경에 최적화된 콘텐츠</div>
<div>...</div>
</>
)}
</div>
);
};
```
Loading