AR
Pokeapp is a Next.js project bootstrapped with
create-next-app.
Start dev server
- Install nested dependencies
$ yarn install
# or
$ npm install- Run the development server:
npm run dev
# or
yarn devDockerize app
- Run
yarn docker:buildimgthis script execute the following command:
$ docker build -t nextjs-initial .- Run
yarn docker:runthis script execute the following command:
$ docker run --name=next-app -p 3000:3000 nextjs-initial- Access to app in your browser typing
https://localhost:3000
Relevant functionality
Incremental Static Regeneration (ISR)
Create static pages with data retrieved from api
getStaticProps: We use it to generate the data that is provided to the
static pages at the server level.getStaticPaths: With this we managed to generate 151 static pages to search
for pokemons by name or id.
Incremental Static Generation (ISG)
Regenerate static pages every determined time or on demand
getStaticProps [revalidate]: It is used to tell next how long it takes to
regenerate the static pages, this time is indicated in seconds. For example,
if we want to do it every 24 hours, the value should be 86400
getStaticPaths
...
fallback: 'blocking', // Allow fallback to render component without pre loaded data
...
getStaticProps
...
if (!pokemon) {
return {
redirect: {
destination: '/',
permanent: false,
}
};
}
return {
props: {
pokemon,
},
revalidate: 86400, // 60 * 60 * 24
};
...
Technology
App Previews
On this page
Languages
TypeScript90.7%Dockerfile7.3%CSS1.3%JavaScript0.7%
Contributors
Created May 10, 2023
Updated May 11, 2023



