# General Translation React SDKs (gt-react, gt-next, gt-react-native): getRegion
URL: https://generaltranslation.com/zh/docs/react/nextjs/reference/functions/get-region.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 使用 General Translation 读取当前 Next.js App Router 请求的地区。getRegion 的 API 参考。

`getRegion` 函数返回当前 App Router 请求对应的地区。在异步组件和其他服务器端代码中，请从 `gt-next/server` 导入它。

`getRegion` 仅可在服务器端使用，不适用于 Pages Router。

## 概览 [#overview]

```tsx
import { getRegion } from 'gt-next/server';

const region = await getRegion(); // 'US' 或 undefined
```

## 返回值 [#returns]

**类型** `Promise<string | undefined>`

一个 Promise，解析结果为 ISO 3166 地区代码；如果未设置地区，则返回 `undefined`。

## 示例 [#example]

```tsx title="app/account/page.tsx"
import { getRegion } from 'gt-next/server';

export default async function AccountPage() {
  const region = await getRegion();
  return <p>Region: {region ?? 'Not set'}</p>;
}
```

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
