# gt-next: General Translation Next.js SDK: useRegion URL: https://generaltranslation.com/ja/docs/next/api/helpers/use-region.mdx --- title: useRegion description: useRegionフックのAPIリファレンス --- {/* 自動生成: 直接編集せず、代わりに content/docs-templates/ 内のテンプレートを編集してください。 */} ## 概要 `useRegion` フックは、[`` コンテキスト](/docs/next/api/components/gtprovider)から、ユーザーが現在選択しているリージョンを取得します。 `useRegion` はクライアントサイドのフックで、*クライアントサイドのコンポーネントでのみ使用できます*。 アプリが [``](/docs/next/api/components/gtprovider) でラップされていることを確認してください。 ## リファレンス ### 戻り値 `string | undefined` — 現在アクティブなリージョンコード (例: `"US"`、`"CA"`) 。リージョンが設定されていない場合は `undefined` を返します。 *** ## 使用例 ### 基本的な使い方 ```jsx title="RegionDisplay.jsx" copy 'use client'; import { useRegion } from 'gt-next'; export default function RegionDisplay() { const region = useRegion(); // [!code highlight] return

Current region: {region ?? 'Not set'}

; } ``` *** ## 注意 * ユーザーがリージョンを選択していない場合は、`undefined` を返します。 * リージョンは、[``](/docs/next/api/components/region-selector) コンポーネントまたは [`useRegionSelector`](/docs/next/api/helpers/use-region-selector) フックで設定できます。 ## 次のステップ * ユーザーがリージョンを選択できるようにするには [``](/docs/next/api/components/region-selector) を使用してください。 * カスタムリージョンセレクターを作成するには [`useRegionSelector`](/docs/next/api/helpers/use-region-selector) を使用してください。