Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

next js Pages with Dynamic Routes

// create a file in pages/posts/[id].js
//then it will be find at posts/1 , posts/2, ..

//file->  pages/posts/[id].js
import { useRouter } from 'next/router'

const Post = () => {
  const router = useRouter()
  const { id } = router.query

  return <p>Post: {id}</p>
}

export default Post
 
PREVIOUS NEXT
Tagged: #js #Pages #Dynamic #Routes
ADD COMMENT
Topic
Name
9+8 =