From d0c57cf6b3473c2a280ab03059a24f20555e9d3f Mon Sep 17 00:00:00 2001 From: Sam Robbins Date: Sat, 1 Aug 2020 13:12:17 +0100 Subject: [PATCH] Add clarification of routing to a dynamic route (#15771) While it is mentioned in the [link documentation](https://nextjs.org/docs/api-reference/next/link), I think it is useful to also explain in the dynamic route documentation that you need to include the as parameter when routing to a dynamic route/ --- docs/routing/dynamic-routes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/routing/dynamic-routes.md b/docs/routing/dynamic-routes.md index e4d85c0244d1b..304e2ab5913ab 100644 --- a/docs/routing/dynamic-routes.md +++ b/docs/routing/dynamic-routes.md @@ -108,5 +108,6 @@ The `query` objects are as follows: - `pages/post/[pid].js` - Will match `/post/1`, `/post/abc`, etc. But not `/post/create` - `pages/post/[...slug].js` - Will match `/post/1/2`, `/post/a/b/c`, etc. But not `/post/create`, `/post/abc` - Pages that are statically optimized by [Automatic Static Optimization](/docs/advanced-features/automatic-static-optimization.md) will be hydrated without their route parameters provided, i.e `query` will be an empty object (`{}`). +- When routing to a dynamic route using `Link` or `router`, you will need to specify the `href` as the dynamic route, for example `/post/[pid]` and `as` as the decorator for the URL, for example `/post/abc`. After hydration, Next.js will trigger an update to your application to provide the route parameters in the `query` object.