Docs
useOrientation

Manage and respond to changes in device orientation with useOrientation.

Loading...

Installation

pnpm dlx shadcn@latest add https://usekit.kiron.dev/k/use-orientation

Usage

"use client"
 
import * as React from "react"
 
import { useOrientation } from "@/hooks/use-orientation"
 
export function Component() {
  const { angle, type } = useOrientation()
 
  return (
    <div>
      <p>Orientation Type: {type}</p>
      <p>Rotation Angle: {angle}°</p>
    </div>
  )
}

API Reference

Return Values

NameTypeDescription
anglenumberThe current orientation angle of the device in degrees.
typestringThe current orientation type of the device (e.g., portrait-primary, landscape-primary, portrait-secondary, landscape-secondary). If the type cannot be determined, it is UNKNOWN.