Skn0tt / nextjs-nestjs-integration-example

https://nextjs-nestjs-integration-example.now.sh
156 stars 36 forks source link

Just wanted to say thank you! #12

Closed kchojhu closed 3 years ago

kchojhu commented 3 years ago

You made my day because I was exactly looking for NextJS+NestJS solution.

The only suggestion I can make is to pre-fetch the data to highlight the SSR. I definitely got it to work using below code.

export async function getServerSideProps(context) {
  const {data} = await axios.get("http://localhost:3000/api/randomNumber");
  return {
    props: {
      randomNumber: data,
    }, // will be passed to the page component as props
  }
}`
const Home = (props) => {
  return (
    <p>
      Random Number: {props.randomNumber}
    </p>
  )
};
Skn0tt commented 3 years ago

Happy the blog post has been helpful for you :)

Feel free to open a PR with your code, I'll happily merge!