SSG generates pages during the build process, ensuring high performance. The pre-rendered HTML stays the same until the site is rebuilt.
async function fetchData() {
const res = await fetch('https://jsonplaceholder.typicode.com/posts/2');
return res.json();
}
ISG enables static pages to refresh incrementally in the background at a set interval (revalidate), keeping the content up-to-date without needing a complete site rebuild.
async function fetchData() {
const res = await fetch('https://jsonplaceholder.typicode.com/posts/1', {
next: { revalidate: 60 }, // Regenerate page every 60 seconds
});
return res.json();
}
SSR dynamically generates pages on each request, delivering the most up-to-date data. However, it can be slower than SSG due to real-time data fetching.
async function fetchData() {
const res = await fetch('https://jsonplaceholder.typicode.com/posts/3', {
cache: 'no-store', // Always fetch fresh data on every request
});
return res.json();
}
Ready to transform your business with our technology solutions? Contact Us today to Leverage Our ReactJS Expertise.