Skip to content
Discussion options

You must be logged in to vote

If i understand correctly, this seems to work for me:

/pages/products/[slug]/index.js

import Link from 'next/link'

export default function SlugPage({ params }) {
  return (
    <div>
      <Link href="/products/[slug]" as="/products/baz">
        baz
      </Link>
      <Link href="/products/[slug]" as="/products/abc">
        abc
      </Link>
      <pre>{JSON.stringify(params, null, 2)}</pre>
    </div>
  );
}

export async function getServerSideProps(context) {
  return {
    props: { params: context.params }, 
  };
}

getServerSideProps is called each time I click a link (via an XHR request).

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@timmysmalls
Comment options

Comment options

You must be logged in to vote
1 reply
@timmysmalls
Comment options

Answer selected by jamesmosier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants