Skip to content

Instantly share code, notes, and snippets.

@shameemreza
Last active January 27, 2023 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shameemreza/32106d71aa40cf6d013551c1d7a48319 to your computer and use it in GitHub Desktop.
Save shameemreza/32106d71aa40cf6d013551c1d7a48319 to your computer and use it in GitHub Desktop.
Example of Mastering the Art of Server-Side Rendering with Next.js
import axios from 'axios'
const About = ({ data }) => {
return (
<div>
<h1>About Our App</h1>
<p>Our app is the best thing since sliced bread.</p>
<p>Data from API: {data}</p>
</div>
)
}
About.getInitialProps = async () => {
const response = await axios.get('https://my-api.com/data')
return { data: response.data }
}
export default About
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment