next.js/test/e2e/app-dir/shallow-routing/app/(shallow)/pushstate-new-pathname/page.tsx
page.tsx23 lines529 B
'use client'
import { usePathname } from 'next/navigation'

export default function Page() {
  const pathname = usePathname()
  return (
    <>
      <h1 id="pushstate-pathname">PushState Pathname</h1>
      <pre id="my-data">{pathname}</pre>
      <button
        onClick={() => {
          const url = new URL(window.location.href)
          url.pathname = '/my-non-existent-path'
          window.history.pushState({}, '', url)
        }}
        id="push-pathname"
      >
        Push pathname
      </button>
    </>
  )
}
Quest for Codev2.0.0
/
SIGN IN