Link to page with tabs

Hi! I've got a page in my ct3a project which has three "tabs" one can open (only one at a time). By default when opening the page, the first tab is open. However I want to redirect a user to the page with a specific tab open. What'd be the best/standard way to do this? Something with dynamic routing? Cookies?
7 Replies
Neto
Neto3y ago
query params /[route]?tab=2 as an example
Vincent Udén
Vincent UdénOP3y ago
Allright, and that would be what Next describes under dynamic routing https://nextjs.org/docs/routing/dynamic-routes ?
Routing: Dynamic Routes | Next.js
Dynamic Routes are pages that allow you to add custom params to your URLs. Start creating Dynamic Routes and learn more here.
Neto
Neto3y ago
no query param is just a web thing the [route] was just my placeholder for your route /?tab=2 /my/deep/nested/page?tab=2
Vincent Udén
Vincent UdénOP3y ago
Oh, that's even better. How'd I access that parameter in my .tsx file?
Neto
Neto3y ago
const { query } = useRouter()
const { query } = useRouter()
on query you have the query params
Vincent Udén
Vincent UdénOP3y ago
Perfect! Thanks a ton
Neto
Neto3y ago
happy
Want results from more Discord servers?
Add your server