-
-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ESM builds for react-server to avoid a circular dependency issue …
…and fix API route
- Loading branch information
Showing
5 changed files
with
20 additions
and
8 deletions.
There are no files selected for viewing
12 changes: 9 additions & 3 deletions
12
examples/example-next-13-advanced/src/app/[locale]/api/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import {NextRequest, NextResponse} from 'next/server'; | ||
import {getTranslations} from 'next-intl/server'; | ||
import {getTranslator} from 'next-intl/server'; | ||
|
||
export async function GET(request: NextRequest) { | ||
type Props = { | ||
params: { | ||
locale: string; | ||
}; | ||
}; | ||
|
||
export async function GET(request: NextRequest, {params: {locale}}: Props) { | ||
const name = request.nextUrl.searchParams.get('name'); | ||
if (!name) { | ||
return new Response('Search param `name` was not provided.', {status: 400}); | ||
} | ||
|
||
const t = await getTranslations('ApiRoute'); | ||
const t = await getTranslator(locale, 'ApiRoute'); | ||
return NextResponse.json({message: t('hello', {name})}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters