Entradas

Mostrando las entradas etiquetadas como dynamic routes

16. Next.js Tutorial (3). Dynamic Routes. Async functions getStaticPaths and getStaticProps

1. Dynamic page Source:  https://nextjs.org/learn/basics/dynamic-routes/implement-getstaticpaths Source:  https://nextjs.org/learn/basics/dynamic-routes/implement-getstaticprops 1. Create a page at /pages/posts/[id].js where the brackets "[]" means a dynamic page 2. This file must contain: A React component to render this page getStaticPaths  async function that returns an array of possible values of id. And has the fallback property. This function is called at build time and needs to be exported ( export async function getStaticPaths() ) getStaticProps  async which fetches necessary data for the post with the id; and needs to be exported too ( export async function  getStaticProps ()  ) The fallback property of the  getStaticPaths  means: If fallback is false , then any paths not returned by getStaticPaths will result in a 404 page . If fallback is true , it will serve the paths generated at build time. If it was not generated at buil...