Skip to content

Instantly share code, notes, and snippets.

@sand97
Last active January 10, 2022 16:47
Show Gist options
  • Save sand97/bfde534da67dd15e4e754b7148c5af32 to your computer and use it in GitHub Desktop.
Save sand97/bfde534da67dd15e4e754b7148c5af32 to your computer and use it in GitHub Desktop.
state inside urls
import {useRouter} from "next/router";
//...
const router = useRouter();
const {router_steep} = router.query
const steep = (isNaN(+router_steep) || +router_steep < 0) ? 0
: +router_steep;
const setSteep = (router_steep: number) => router.push(
`/https://your.website.com?router_steep=${router_steep}`,
undefined, {shallow: true});
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment