Skip to content

Instantly share code, notes, and snippets.

@brandonchadlange
Created September 22, 2022 20:46
Show Gist options
  • Save brandonchadlange/a57a9acc4422c3dca2cb532f61b6954a to your computer and use it in GitHub Desktop.
Save brandonchadlange/a57a9acc4422c3dca2cb532f61b6954a to your computer and use it in GitHub Desktop.
Messy next.js routing example
import { useRouter } from "next/router";
const MessyRouter = () => {
const router = useRouter();
const { organisation, workspace } = router.query;
const route1 = `/${organisation}/${workspace}/route-1`
const route2 = `/${organisation}/${workspace}/route-2`;
return (
<ul>
<li>
<a href={route1}>Route 1</a>
</li>
<li>
<a href={route2}>Route 2</a>
</li>
</ul>
);
};
export default MessyRouter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment