LoginSignup
4
2

More than 3 years have passed since last update.

Next.jsでURLパラメータを取得する

Posted at

getServerSidePropsを使う

http://localhost:3000/hoge?slug=tokyo
このslug部分を取得したい。

export async function getStaticProps({query}) {
  console.log(query.slug)
  return {}
}
// undefined

export async function getServerSideProps({query}) {
  console.log(query.slug)
  return {}
}
// tokyo

詳細はこちらに

4
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2