Skip to content

Instantly share code, notes, and snippets.

@PaulieScanlon
Created April 5, 2024 19:36
Show Gist options
  • Save PaulieScanlon/936cdff6e1c52b44a721f0b29dda4842 to your computer and use it in GitHub Desktop.
Save PaulieScanlon/936cdff6e1c52b44a721f0b29dda4842 to your computer and use it in GitHub Desktop.
Example Next.js Route (Pages Router)
// pages/index.js
import ParentComponent from '../components/parent-component';
const Page = ({ data }) => {
return <ParentComponent data={data} />;
};
export async function getServerSideProps() {
const response = await fetch('https://api.github.com/repos/vercel/next.js');
const data = await response.json();
return { props: { data } };
}
export default Page;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment