<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bartlomiej Wendt on Medium]]></title>
        <description><![CDATA[Stories by Bartlomiej Wendt on Medium]]></description>
        <link>https://medium.com/@bartek.wendt?source=rss-cde2976475e9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZE-4FT6LoBOGMIioiC4a8A.jpeg</url>
            <title>Stories by Bartlomiej Wendt on Medium</title>
            <link>https://medium.com/@bartek.wendt?source=rss-cde2976475e9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 15:09:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bartek.wendt/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Getting Started with Next.js]]></title>
            <link>https://medium.com/@bartek.wendt/getting-started-with-next-js-f2d3bb2b9e78?source=rss-cde2976475e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2d3bb2b9e78</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[seo]]></category>
            <dc:creator><![CDATA[Bartlomiej Wendt]]></dc:creator>
            <pubDate>Fri, 08 Oct 2021 21:15:55 GMT</pubDate>
            <atom:updated>2021-10-08T21:15:55.388Z</atom:updated>
            <content:encoded><![CDATA[<p>A quick guide on how to start a project in Next.js. We will cover all what’s, why’s, and how’s as well as provide you with lots of useful curiosities.</p><h3>Introduction</h3><p>When I first started writing front-end, I have been using create-react-app for most of my personal projects. I really liked how easy it was to start a React project with create-react-app but over time as I gained some more experience I noticed that it was missing some features that could help both with development and my project itself. Then I started looking for improved alternatives and that’s how I found out about Next.js.</p><h3>What is Next.js?</h3><figure><img alt="Next.js" src="https://cdn-images-1.medium.com/max/1000/1*htbUdWgFQ3a94PMEvBr_hQ.png" /></figure><p>Next.js is an open-source production React framework that <strong>enables several extra features, including server-side rendering, generating static websites, and great SEO optimizations</strong>. Traditional React apps render all their content in the client-side browser, Next.js is used to extend this functionality to include applications rendered on the server-side.</p><p>Next.js gives us a lot of additional features and possibilities that are definitely worth your while, for instance:</p><ul><li>Hot Reloading — Next.js reloads the page when it detects any changes saved to disk.</li><li>File-system routing — All of your files inside the <strong>pages</strong> folder are mapped to the filesystem without any additional configuration.</li><li>Server-side rendering — The HTML is generated on<strong> each request.</strong></li><li>Static generation — Generating HTML at <strong>build time</strong> that will be reused one each request.</li><li>Automatic code splitting -Instead of generating one single JavaScript file containing all the app code, the app is broken up automatically by Next.js in several different resources.</li><li>TypeScript support</li></ul><p>and many more!</p><p>If you want to learn from their dedicated tutorial you can visit <a href="https://nextjs.org/learn/basics/create-nextjs-app?utm_source=next-site&amp;utm_medium=homepage-cta&amp;utm_campaign=next-website">this website</a>.</p><h3>Why Use Next.js?</h3><p>Besides the features mentioned above, there are other reasons to use Next.js.</p><p>If you want to build a solid web application with React from scratch, you have to consider many important details such as:</p><ul><li>Code has to be bundled using a bundler like webpack and transformed using a compiler like Babel.</li><li>You need to optimize your production with techniques like code splitting.</li><li>You might have to take care of statically pre-rendering pages for performance and SEO.</li><li>Maybe you would like to use server-side rendering or client-side rendering.</li><li>Writing some server-side code to connect your React app to your data store.</li></ul><p>Next.js framework can solve these problems and provide you with a great “Developer Experience” at the same time, ensuring you and your team have an amazing adventure working with it.</p><h3>Basics in a Nutshell</h3><p>It can be quite hard to jump into new technology when there are so many new features and things that you’ve never heard of before.</p><p>To help you with that we will now go step by step through all of the most important features that Next.js provides. I’ll try to explain them in the simplest way I can so that you can grasp them without any problems and put them into practice in your <em>next</em> Next.js app.</p><h3>Server-side rendering</h3><p>There are two forms of pre-rendering content in the Next.js app and one of them is server-side rendering also known as SSR. We should use SSR only if it is absolutely necessary because the HTML is being <strong>generated on each request</strong> and this results in much slower performance than Static Generation.</p><p>In order to use it for a page, you need to use export an async function <strong><em>getServerSideProps</em></strong><em> </em>on your page. This function will be called by the server on every request.</p><figure><img alt="Next.js SSR documentation example" src="https://cdn-images-1.medium.com/max/1024/1*E05YbhrXjg4LZPJrsbJXtQ.png" /><figcaption>Next.js SSR documentation example</figcaption></figure><p>It can be used for Data Fetching in your application.</p><p>Learn more about how it works <a href="https://nextjs.org/docs/basic-features/data-fetching#getserversideprops-server-side-rendering">here</a>.</p><h3>Static generation</h3><p>The second option for our pre-rendering in a Next.js app is a static generation (SSG) which is recommended in most cases. In this case, the HTML is <strong>generated at build time and will be reused on each request</strong>. You can also use it with Client-side Rendering like in regular React to bring in additional data.</p><p>If you export an async function called <strong><em>getStaticProps</em></strong> on a page, then this page will pre-render at build time with props returned from this function.</p><p>We should use<strong> <em>getStaticProps </em></strong>when data on the page is available ahead of the user’s request, for example, blog posts from headless CMS or pages simply need to be blazing fast and pre-rendered for best SEO performance.</p><figure><img alt="Next.js SSG documentation example" src="https://cdn-images-1.medium.com/max/1024/1*xF-T29JUXxre5NGnflqzLw.png" /><figcaption>Next.js SSG documentation example</figcaption></figure><p>More Next.js SSG documentation to deep dive is available <a href="https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation">here</a>.</p><h3><strong>File-system routing</strong></h3><p>In React, you have to deal with routing by yourself either by using react-router-dom or writing the custom routing system by yourself and it can be complicated and time-consuming. Next.js helps you with that with a built-in intuitive file-system routing that will assist you to organize routes easier.</p><p>It is worth mentioning that routing is strictly connected with your /pages directory structure and because of that, you can’t modify the way it deals with routes so it can be a bit opinionated in this case.</p><p>When you create a page file or nested directory inside the <strong>/pages folder</strong>, it will be automatically available as a route in your Next.js application. Default Next.js URL route is created from pages index.js file.</p><figure><img alt="File-system routing graphic explanation" src="https://cdn-images-1.medium.com/max/526/1*4FJBIzaEsyG63DoKRiMftA.png" /><figcaption>File-system routing graphic explanation</figcaption></figure><p>Visit Next.js Routing <a href="https://nextjs.org/docs/routing/introduction">documentation</a> to find out more.</p><p><strong>Assets and CSS</strong></p><p>Next.js can serve static assets like images under the /<strong><em>public </em></strong>directory. Everything inside this folder can be later referenced in a similar way to how our routes work. This is also a place in which you would like to put your robots.txt for Google Site Verification.</p><p>To use an image that is being served as a static asset just create<strong><em> /images</em></strong> folder in your /<strong><em>public </em></strong>folder and use it in the following way:</p><pre>&lt;img src=&quot;/images/teacode-logo.png&quot; alt=&quot;teacode green leaf&quot; /&gt;</pre><p>Next.js has built-in support for styled-JSX, CSS, and Sass.</p><p>A good option to consider and focus on is to use the CSS-in-JSS library. Some great examples that I highly recommend looking at are <a href="https://emotion.sh/docs/introduction">Emotion</a> and <a href="https://styled-components.com/">styled-components</a>.</p><h3>How to start a new Next.js application</h3><p>To install Next.js, you’ll need<strong> Node.js</strong> version <strong>10.13</strong> or later.</p><p>In order to check your current version simply type “<strong>node — version</strong>” in your terminal (Mac, Linux) or cmd (Windows). If you have an older version, you can get the latest one from <a href="https://nodejs.org/en/">here</a>.</p><p><strong>Using Create Next App</strong></p><p>The easiest way to create a Next.js application is by using create-next-app. It is actually the same thing as create-react-app except it creates a Next app for you instead of React app.</p><p>To start, type the command shown below in your terminal or cmd.</p><pre>npx create-next-app <br><br># or <br><br>yarn create next-app</pre><p>To use TypeScript you’ll have to provide the “ — ts” or “ — typescript” flag.</p><pre>npx create-next-app --ts <br><br># or <br><br>yarn create next-app --typescript</pre><p>If everything went fine, you should see a piece of success information in your terminal. To start the development use one of these commands.</p><pre>npm run dev<br><br># or<br><br>yarn dev</pre><p>To see how it looks like, let’s follow suggestions from the terminal and head to<strong> localhost:8000</strong></p><p>And that’s it. We have created a very basic Next.js application using create-next-app. To learn more about create-next-app and how to create production build please visit the documentation <a href="https://nextjs.org/learn/basics/create-nextjs-app">here</a>.</p><figure><img alt="Next.js start localhost:8000" src="https://cdn-images-1.medium.com/max/1024/1*oLC7M9nQEaJ4KlTbmDA5DQ.png" /><figcaption>localhost:8000</figcaption></figure><h3>Manually create Next.js project</h3><p>You don’t always have to use create-next-app while initializing your project if there are any reasons you want to avoid using it or you simply want to create the Next app from scratch, you can do it in just a few simple steps.</p><p>1. Create a new empty directory and initialize the Node project with npm init.</p><pre># Create empty directory <br>  mkdir teacode-rocks <br><br># Move to /teacode-rocks directory <br>  cd teacode-rocks <br>  <br> # Initialize Node project<br>   npm init -y</pre><p>2. Install next, react, and react-dom.</p><pre>npm install next react react-dom</pre><p>3. Add scripts to your package.json file.</p><pre>&quot;scripts&quot;: { <br>    &quot;dev&quot;: &quot;next&quot;, <br>    &quot;build&quot;: &quot;next build&quot;, <br>    &quot;start&quot;: &quot;next start&quot; <br>}</pre><p>4. Add /pages directory and create _app.js file inside it.</p><pre>function MyApp({ Component, pageProps }) { <br>  return &lt;Component {...pageProps} /&gt;; <br>} <br><br>export default MyApp;</pre><p>5. Create an index.js inside it.</p><pre>import Head from &#39;next/head&#39; <br><br>export default function Home() { <br>  &lt;div&gt; <br>    &lt;Head&gt; <br>      &lt;title&gt;Teacode Rocks!&lt;/title&gt;<br>    &lt;/Head&gt;<br>    &lt;main&gt;<br>      &lt;h1&gt;This is my manually set-up Next.js project!&lt;/h1&gt;<br>    &lt;/main&gt;<br>  &lt;/div&gt; <br>}</pre><p>6. Run your app!</p><pre>npm run dev</pre><p>In order to find out how to customize your manual set-up Next.js app and use advanced features visit Next.js documentation <a href="https://nextjs.org/docs">here</a>.</p><p>Now you are ready to go with your very default Next.js project!</p><h3>Conclusion</h3><p>Whether to use Next.js for your next project strongly depends on what you are aiming for.</p><p>Assuming that you want to create a blazing fast, secure and SEO-focused application then Next.js is your way to go.</p><p>As you can see, it gives you a lot of additional features and out-of-the-box solutions that are not accessible for example in create-react-app, and at the same time, the development experience is great.</p><p>If you’ve used React before then starting with Next.js would be easy-peasy for you and you should not worry about that. It has great documentation with a lot of examples for developers that makes working with it really enjoyable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2d3bb2b9e78" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>