<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tim Cheung</title>
    <description>The latest articles on DEV Community by Tim Cheung (@timshingyu).</description>
    <link>https://dev.to/timshingyu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F434540%2F4cc3f10f-00b4-444c-91cb-123d5cf740c1.png</url>
      <title>DEV Community: Tim Cheung</title>
      <link>https://dev.to/timshingyu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/timshingyu"/>
    <language>en</language>
    <item>
      <title>Next.js 9.5 - Stable Incremental Static Regeneration</title>
      <dc:creator>Tim Cheung</dc:creator>
      <pubDate>Wed, 09 Sep 2020 07:07:56 +0000</pubDate>
      <link>https://dev.to/timshingyu/next-js-9-5-stable-incremental-static-regeneration-5gle</link>
      <guid>https://dev.to/timshingyu/next-js-9-5-stable-incremental-static-regeneration-5gle</guid>
      <description>&lt;p&gt;One of the benefits of State Site Generation is that we can keep our site static generated at build time and put all site files distributed to global edge CDN. The result is a fast, reliable, and safe browsing experience.&lt;/p&gt;

&lt;p&gt;However, suppose we need to fetch the dynamic data frequently, and the data source didn't provide any webhook mechanism to rebuild the site. In that case, we need to rebuild the site for every data update manually. It will be tedious tasks to do so.&lt;/p&gt;

&lt;p&gt;To enjoy both worlds, static site generation, and dynamic data fetching without manual site rebuild. Next.js has introduced - Incremental Static Generation feature.&lt;/p&gt;

&lt;p&gt;All you need to do is add the revalidate inside getStaticProps return&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getStaticProps&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;getDataFromCMS&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="c1"&gt;// we will attempt to re-generate the page:&lt;/span&gt;
    &lt;span class="c1"&gt;// - when a request comes in&lt;/span&gt;
    &lt;span class="c1"&gt;// - at most once every second&lt;/span&gt;
    &lt;span class="na"&gt;revalidate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To showcase this great feature, the next.js team has created an example &lt;a href="https://reactions-demo.now.sh/"&gt;https://reactions-demo.now.sh/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n523YvM7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://images.prismic.io/kickstartapp/dd1ed6c0-8011-41f2-b8e7-6c5a915a7f9c_demo.gif%3Fauto%3Dcompress%2Cformat" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n523YvM7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://images.prismic.io/kickstartapp/dd1ed6c0-8011-41f2-b8e7-6c5a915a7f9c_demo.gif%3Fauto%3Dcompress%2Cformat" alt="Demo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By updating the reaction in GitHub, the next app will revalidate and rebuild the page in no time!&lt;/p&gt;

&lt;p&gt;Thanks for reading! You can follow my &lt;a href="https://twitter.com/csytim"&gt;twitter&lt;/a&gt; or &lt;a href="https://kickstart.app/blog"&gt;blog&lt;/a&gt; for more news.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>jamstack</category>
    </item>
  </channel>
</rss>
