From 43937799352b6dda4d2035d70e9bbeb1ac850484 Mon Sep 17 00:00:00 2001 From: Jam Balaya Date: Mon, 16 Dec 2024 05:38:35 +0900 Subject: [PATCH] docs: add `next.config.ts` code switcher to Redirecting docs (#73848) Co-authored-by: Lee Robinson --- .../01-routing/07-redirecting.mdx | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/01-app/03-building-your-application/01-routing/07-redirecting.mdx b/docs/01-app/03-building-your-application/01-routing/07-redirecting.mdx index 4897b8fcd5de7..637a0ce1246b3 100644 --- a/docs/01-app/03-building-your-application/01-routing/07-redirecting.mdx +++ b/docs/01-app/03-building-your-application/01-routing/07-redirecting.mdx @@ -237,7 +237,32 @@ The `redirects` option in the `next.config.js` file allows you to redirect an in To use `redirects`, add the option to your `next.config.js` file: -```js filename="next.config.js" +```ts filename="next.config.ts" switcher +import type { NextConfig } from 'next' + +const nextConfig: NextConfig = { + async redirects() { + return [ + // Basic redirect + { + source: '/about', + destination: '/', + permanent: true, + }, + // Wildcard path matching + { + source: '/blog/:slug', + destination: '/news/:slug', + permanent: true, + }, + ] + }, +} + +export default nextConfig +``` + +```js filename="next.config.js" switcher module.exports = { async redirects() { return [