Skip to content

Instantly share code, notes, and snippets.

@akellbl4
Created June 9, 2021 06:11
Show Gist options
  • Save akellbl4/f945f802738555c1bcb9ff5a14e38fe1 to your computer and use it in GitHub Desktop.
Save akellbl4/f945f802738555c1bcb9ff5a14e38fe1 to your computer and use it in GitHub Desktop.
// lib/router.js
import { useRouter as useNextRouter } from 'next/router'
export function useRouter() {
const router = useNextRouter()
const [pathname, queryString = ''] = router.asPath.split('?')
return Object.assign(router, { pathname, queryString })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment