<?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 Moleseng Mokgosi on Medium]]></title>
        <description><![CDATA[Stories by Moleseng Mokgosi on Medium]]></description>
        <link>https://medium.com/@mmokgosi9?source=rss-a38a0b11e54b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9lkNS3L14PHKqzxPgaDslg@2x.jpeg</url>
            <title>Stories by Moleseng Mokgosi on Medium</title>
            <link>https://medium.com/@mmokgosi9?source=rss-a38a0b11e54b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 03:26:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mmokgosi9/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[web.config: 3 things you can do with it]]></title>
            <link>https://medium.com/@mmokgosi9/web-config-3-things-you-can-do-with-it-5ad825e59c4d?source=rss-a38a0b11e54b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ad825e59c4d</guid>
            <category><![CDATA[web-config]]></category>
            <category><![CDATA[configuration]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[isis]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <dc:creator><![CDATA[Moleseng Mokgosi]]></dc:creator>
            <pubDate>Wed, 23 Aug 2023 10:11:54 GMT</pubDate>
            <atom:updated>2023-08-23T10:11:54.965Z</atom:updated>
            <content:encoded><![CDATA[<h3>web.config: 3 Things you can do with this file</h3><p>This is a quick introduction to the web.config file. I will also cover the top 3 things you can set up in this file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*IgMn-5a-ooV47yBh-GfKbw.png" /><figcaption>Image by author</figcaption></figure><h4>What is the purpose of a web.config file?</h4><p>The web.config is a file that is read by Internet Information Services (IIS) and the ASP.NET Core Module to configure various settings and behaviors of an application hosted with IIS.</p><h4>Why web.config?</h4><p>Most of the configuration settings you can customise in the web.config file can also be configured in the appsettings.json files, so why would you want to use this file instead? There are <a href="https://www.c-sharpcorner.com/blogs/webconfig-settings-and-configuration-file-advantages1">many benefits</a> to using the web.config file to configure settings for your application.</p><ul><li>The web.config file is written in XML, which makes it readable and easy to understand.</li><li>The application logic is separated from the configuration logic.</li><li>You can create a set of hierarchal configurations for different parts of your application. By placing a web.config file in different sub-directories, you can have specialized sets of rules for different sections of your application.</li><li>You need to have the web.config file in your application hosted on IIS anyway, so why not use that file for configuration settings?</li></ul><h4>Do I need a web.config file in my project?</h4><blockquote>The web.config file must be present in the deployment at all times, correctly named, and able to configure the site for normal start up.</blockquote><p>This is because <a href="https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/web-config?view=aspnetcore-7.0">sensitive files exist on the app’s physical path</a> and if the web.config file is missing or named incorrectly, IIS may serve these files to the client. If the web.config file is present, IIS will not serve these sensitive files if they are requested.</p><p>NB: You must never remove the web.config file from a production deployment.</p><h3>What are 3 things that I can configure in the web.config file?</h3><h4>1. Configure file upload size</h4><p>You can adjust the maximum file upload size for your ASP .Net project in the web.config file. By default, the maximum upload size is 30mb (or 31 457 280 bytes) <a href="https://www.talkingdotnet.com/how-to-increase-file-upload-size-asp-net-core/">for each upload</a>.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;configuration&gt;<br>  &lt;system.webServer&gt;<br>      &lt;security&gt;<br>        &lt;requestFiltering&gt;<br>          &lt;!-- This will handle requests up to 50MB --&gt;<br>          &lt;requestLimits maxAllowedContentLength=&quot;52428800&quot; /&gt;<br>        &lt;/requestFiltering&gt;<br>      &lt;/security&gt;<br>    &lt;/system.webServer&gt;<br>&lt;/configuration&gt;</pre><p>Setting the maxAllowedContentLength to 52428800 Bytes will increase the maximum allowed file upload size from 30MB to 50MB.</p><p>Additionaly, we set the the maximum allowed size of any request body in bytes with MaxRequestBodySize in the <a href="https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.builder.iisserveroptions?view=aspnetcore-7.0">IISServerOptions</a> class inside the Program.cs file to allow the increased file upload size.</p><pre>services.Configure&lt;IISServerOptions&gt;(options =&gt;<br>{<br> //maximum allowed files of 50mb in bytes<br> options.MaxRequestBodySize = 50 * 1024 * 1024;<br>});</pre><p>Finally, go into your server using the IIS Manager GUI and see that the Maximum allowed content length value in the request filtering settings for the domain is set from 36700160 bytes to 52428800 bytes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*QpbXzQ8_0EQ36f_xu3IuMQ.png" /><figcaption>IIS Manger GUI</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47B-0GR8y-PjLe-LxOplvg.png" /><figcaption>Default values for Request Limits on IIS Server.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*FWRhQ16ivKDWikoj9eg3DQ.png" /><figcaption>Maximum allowed content (Bytes) increased to 50MB.</figcaption></figure><p>The default ASP.NET Core application template doesn’t create the web.config file and it is only automatically created when you publish the application. However, you can add it manually to the root of the application.</p><h4>2. Configure redirect settings</h4><p>You can configure HTTP modules and handlers in the web.config file. Modules and handlers can be used to intercept and process incoming requests to your application so you can use it for tasks such as URL rewriting, authentication, or custom request processing.</p><p>The example below shows how you can rewrite the URL of an incoming request to redirect HTTP (non-secure) traffic to HTTPS (secure).</p><pre>&lt;rule name=&quot;RedirectToHTTPS&quot; stopProcessing=&quot;true&quot;&gt;<br>  &lt;match url=&quot;(.*)&quot; /&gt;<br>  &lt;conditions&gt;<br>    &lt;add input=&quot;{HTTPS}&quot; pattern=&quot;off&quot; ignoreCase=&quot;true&quot; /&gt;<br>  &lt;/conditions&gt;<br>  &lt;action type=&quot;Redirect&quot; url=&quot;https://{SERVER_NAME}/{R:1}&quot; redirectType=&quot;Permanent&quot; /&gt;<br>&lt;/rule&gt;</pre><ul><li>The rule tag defines a rule named “RedirectToHTTPS” to redirect traffic to HTTPS.</li><li>&lt;match url=&quot;(.*)&quot; /&gt; defines a URL pattern to be matched.</li><li>input=”{HTTPS}” this line checks the value of the {HTTPS} server variable. The pattern checks if the value input received is “on” or “off” for the pattern defined in the input.</li><li>&lt;action type=”Redirect” url=”https://{SERVER_NAME}/{R:1}&quot; redirectType=”Permanent” /&gt; defines what should happen if the server variable is found to be HTTP. The action here is a redirect to the HTTPS version of the same URL.</li></ul><p>Having access to redirect traffic is very important because as you can see in the example above, you can ensure that the client visits your site using a secure connection and that any sensitive information is transmitted securely. There are <a href="https://blog.elmah.io/web-config-redirects-with-rewrite-rules-https-www-and-more/">so many more</a> behaviours you can customise from the web.config file.</p><h4>3. Custom error pages</h4><pre>&lt;configuration&gt;<br>    &lt;system.web&gt;<br>       &lt;customErrors mode=&quot;On&quot; defaultRedirect=&quot;apperror.cshtml&quot;&gt;<br>          &lt;error statusCode=&quot;404&quot; redirect=&quot;404.cshtml&quot; /&gt;<br>          &lt;error statusCode=&quot;500&quot; redirect=&quot;500.cshtml&quot; /&gt;<br>       &lt;/customErrors&gt;<br>    &lt;/system.web&gt;<br>&lt;/configuration&gt; </pre><p>The defaultRedirect attribute specifies the default page the user will be redirected to in the instance of an unhandled error. For any <strong>unhandled </strong>exceptions, the user will be redirected to the “apperror.cshtml” page.</p><p>You can then specify pages for the instances when you want to take users to specific pages when an error occurs using the &lt;error&gt; tag and the redirect attribute.</p><ul><li>An error with a statusCode of 404 <em>(Not Found)</em> will redirect the user to the “404.cshtml” page.</li><li>An error with a statusCode of 500 <em>(Internal Server Error)</em> error will redirect the user to the “500.cshtml” page.</li></ul><p>You can customise even <a href="https://www.c-sharpcorner.com/UploadFile/puranindia/Asp-Net-web-configuration-file/#:~:text=A%20configuration%20file%20(web.,separate%20from%20your%20application%20code.">more</a> settings from this file, including:</p><ul><li>Database connection strings</li><li>Security settings</li><li>Caching settings</li></ul><h4>What are some disadvantages of using this file?</h4><p>The web.config file is pushed along with the rest of your code to the repository so you should never store sensitive information in your code.</p><p>You don’t want to include API Keys and connection strings especially in the production environment. Although it is possible to configure these values directly in the web.config file you will not want to store any secret values in this file. <a href="https://learn.microsoft.com/en-us/aspnet/identity/overview/features-api/best-practices-for-deploying-passwords-and-other-sensitive-data-to-aspnet-and-azure">Here are some techniques</a> you can use to define sensitive values in an external file and calling them into the configuration files that will be pushed to your repository.</p><h4>Conclusion</h4><p>The web.config file provides us with a powerful set of configuration possibilities that can set up centrally and flexibly. We are able to control various aspects of the behaviour of our application, but we also have to be careful not to leave sensitive information in this file as it can be accessed from your application’s repository.</p><p>Thank you for taking the time to read this article and I hope it helped you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ad825e59c4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Dive into Implementing react-native-image-picker]]></title>
            <link>https://medium.com/@mmokgosi9/deep-dive-into-implementing-react-native-image-picker-c1567484a53?source=rss-a38a0b11e54b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1567484a53</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[image]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Moleseng Mokgosi]]></dc:creator>
            <pubDate>Wed, 26 Apr 2023 10:30:43 GMT</pubDate>
            <atom:updated>2023-04-26T10:30:43.895Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oGMoeykeYhRQQbO_4zMx2A.png" /><figcaption>Image by author</figcaption></figure><p>Providing users with the ability to upload pictures on their profiles is standard in modern applications. It is very important to give users the best experience so they can keep coming back to your app.</p><p>If you’re building your mobile app with React-Native, this is very easy to accomplish thanks to react-native-image-picker.</p><h3>What image format should my app support?</h3><p>The first question you have to ask yourself is “What image types should my app support?”. There are a plethora of image types out there, and it can get overwhelming and confusing especially if you want your app to cater to all kinds of people. React Native actually makes this super easy for us.</p><blockquote>“The currently supported formats are png, jpg, jpeg, bmp, gif, webp, psd (iOS only). In addition, iOS supports several RAW image formats.”</blockquote><p>So you can narrow down your choices. Not mentioned in this list is the Base64. Base64 is a group of binary-to-text encoding schemes that represent binary data.</p><h3>React-Native-Image-Picker</h3><h4>What is React Native Image Picker?</h4><p>React-Native-Image-Picker is a React Native module that allows you to use native UI to select media from the device library or directly from the camera. It is currently used by almost 60 000 developers, as it is quite robust in what it offers.</p><h4>Installing and setting up React-Native-Image-Picker</h4><p>Start by installing the package to your project:</p><p>Android:</p><pre>yarn add react-native-image-picker</pre><p>iOS:</p><pre>npx pod-install ios</pre><p>On the react-native-image-picker repository, there is advise on some post-install steps. These include:<br>If you are allowing user to select image/video from photos, add NSPhotoLibraryUsageDescription.</p><p><strong>iOS</strong></p><blockquote>If you are allowing user to capture image add NSCameraUsageDescription key also.</blockquote><blockquote>If you are allowing user to capture video add NSCameraUsageDescription add NSMicrophoneUsageDescription key also.</blockquote><p><strong>Android</strong></p><p>Permissions are not required unless you have the saveToPhotos property set to true.</p><p><strong>Permissions for iOS go in the Info.plist file in the test folder as follows:</strong></p><pre>&lt;key&gt;NSPhotoLibraryUsageDescription&lt;/key&gt;<br> &lt;string&gt;$(PRODUCT_NAME) would like access to your photo gallery&lt;/string&gt;<br>&lt;key&gt;NSCameraUsageDescription&lt;/key&gt;<br> &lt;string&gt;$(PRODUCT_NAME) would like to use your camera&lt;/string&gt;</pre><h4>Permissions for Android go into the AndroidManifest.xml file :</h4><p>The React-Native-Image-Picker module does not need permissions to work for your users, but if you do set up the option to save images captured on the app to gallery, you will need one permission:</p><pre>&lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;/&gt;</pre><p>Here you are asking your user for permission to access their gallery and save the images captured from the application to their gallery.</p><h4>Implementing React-Native-image-Picker</h4><p>Create a component Profile.js. react-native-image-picker has two methods we can use; launchCamera() which will launch the camera to take a picture and launchImageLibrary() which will launch the gallery to pick a picture or video. We will import these into our file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ed17c3a9eb9aa657f0d17bb0898d463/href">https://medium.com/media/7ed17c3a9eb9aa657f0d17bb0898d463/href</a></iframe><p>The launchLibrary method launches the user’s gallery and takes two parameters; configurations for the image and a response.</p><blockquote>Image/video captured via camera will be stored in temporary folder so will be deleted any time, so don’t expect it to persist. Use saveToPhotos: true (default is false) to save the file in the public photos. saveToPhotos requires WRITE_EXTERNAL_STORAGE permission on Android 28 and below (You have to obtain the permission, the library does not).</blockquote><p>The launchCamera method launches the user’s camera and and also takes two parameters; configurations for the image and a response.</p><p>The pickerResponse state variable is to save the response from the image picker. The imageFromDB state variable is to save the image from the database so we can access it later.</p><p>We use the Image component as follows:</p><pre><br><br>&lt;Card style=//card styles, specifically if you want the image to have elevation&gt;<br>    &lt;Image<br>        source={{<br>          uri: `data:image/*;base64,${imageFromDB}`,,<br>          width: ..,<br>          height: ...,<br>        }}<br>        style=//extra image styles<br>    /&gt;<br>&lt;/Card&gt;<br>   </pre><p>This line of code</p><pre>uri: `data:image/*;base64,${imageFromDB}`,</pre><p>means that we use the uri property to render the image from the database and image/* is a catchall that will make sure that the component renders whichever image type.</p><p>We can also add a pressable icon to activate a modal where the user can choose to access their gallery or camera to upload an image.</p><pre> &lt;Pressable<br>    style={({ pressed }) =&gt; [<br>        {<br>            ...styles.cameraIconView,<br>            opacity: pressed ? 0.5 : 1,<br>        },<br>    ]}<br>    onPress={() =&gt; setVisible(true)}<br>&gt;<br>    &lt;IconComponent<br>        source={icons.camera}<br>        tintColor={themeColor.primaryWhite}<br>    /&gt;<br>&lt;/Pressable&gt;</pre><p>We want to put the modal in our Profile component and pass it all the necessary properties.</p><pre>&lt;ImagePickerModal<br>    isVisible={visible}<br>    onClose={() =&gt; setVisible(false)}<br>    onImageLibraryPress={onImageGalleryPress}<br>    onCameraPress={onCameraPress}<br>/&gt;</pre><p>Finally, we will need to create an ImagePickerModal component.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a33f976da982cc2018119d8986e27e3c/href">https://medium.com/media/a33f976da982cc2018119d8986e27e3c/href</a></iframe><p>For those of you wondering why we are using a base64 image instead of sending the image as is to the database, base64 encoding reduces the size of data by up to 33% and many programming languages have built in support for base64 encoding.</p><h3>Conditionally rendering the image depending on the state of the page</h3><p>To render our image, we will be looking at 3 cases:</p><ol><li>The user is not logged in</li><li>The user is logged in but does not have a profile image</li><li>The user is logged in and does have a profile image</li><li>The user is logged in and just changed their profile image</li></ol><pre>userLoggedIn ? {<br>  uri ? (<br>    &lt;Card style={styles.userDBImageView}&gt;<br>        &lt;Image<br>            source={{<br>                uri: uri,<br>                width: styles.userDBImage.width,<br>                height: styles.userDBImage.height,<br>            }}<br>            style={styles.userDBImage}<br>        /&gt;<br>    &lt;/Card&gt;<br>) : imageFromDB ? (<br>    &lt;Card style={styles.userDBImageView}&gt;<br>        &lt;Image<br>            source={{<br>                uri: `data:image/*;base64,${imageFromDB}`,<br>                width: styles.userDBImage.width,<br>                height: styles.userDBImage.height,<br>            }}<br>            style={styles.userDBImage}<br>            // tintColor={colors.primaryWhite}<br>        /&gt;<br>    &lt;/Card&gt;<br>) : (<br>    &lt;Card<br>        style={{<br>            ...styles.userImageView,<br>            marginTop: &#39;8%&#39;,<br>            width: &#39;25%&#39;,<br>        }}<br>    &gt;<br>        &lt;Image<br>            source={icons.profileImage}<br>            style={styles.userImage}<br>            tintColor={colors.primaryWhite}<br>        /&gt;<br>    &lt;/Card&gt;<br>)<br>) : (<br>&lt;Card style={styles.userImageView}&gt;<br>    &lt;Image<br>        source={icons.profileImage}<br>        style={styles.userImage}<br>        tintColor={colors.primaryWhite}<br>    /&gt;<br>&lt;/Card&gt;<br>         )<br>}</pre><h4>User is not logged in</h4><p>The last component will be the one to be called when the user is not logged in, so the source for that image should be the default/fallback image.</p><h4>The user is logged in but does not have a profile image</h4><p>When the user is logged in but does not have a profile image, we will show the same image as when the user is not logged in, which is the second last component in the code.</p><h4>The user is logged in and does have a profile image</h4><p>The second component is rendered when a check has been executed to see if the user has logged in and if the user has an image from the database</p><h4>The user is logged in and just changed their profile image</h4><p>This code snippet first looks at if the user has selected/captured a new image using the uri variable. If there is a value for uri, it will immediately get displayed since it has precedence over the other variables in the ternary operator.</p><h3>Conclusion</h3><p>react-native-image-picker makes implementing image uploading capabilities very easy. It is so robust in its offering that you can easily build yourself an application where users can upload images and videos. It also helps make user experience pleseant but the best part about it is that it makes the developer experience even more enjoyable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1567484a53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud — A Beginner’s Guide for Software Developers]]></title>
            <link>https://medium.com/@mmokgosi9/cloud-a-beginners-guide-for-software-developers-5628434c83d6?source=rss-a38a0b11e54b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5628434c83d6</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[microsoft]]></category>
            <dc:creator><![CDATA[Moleseng Mokgosi]]></dc:creator>
            <pubDate>Thu, 17 Nov 2022 07:43:29 GMT</pubDate>
            <atom:updated>2022-11-17T09:12:06.989Z</atom:updated>
            <content:encoded><![CDATA[<h3>Cloud — A Beginner’s Guide for Software Developers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*518VDJBA4uTYYfYoM4Mj4A.jpeg" /><figcaption>Image from <a href="https://www.freepik.com/">freepik</a></figcaption></figure><p>As software developers, we work in an industry where the only constant is change. The world of technology is always moving foward and excelling at insane rates. Changes are happening at every moment of the day, and one of the changes at the very center of it all are happening because of <em>THE CLOUD</em>.</p><p>Seeing as tech has so many different things going on, it may be hard to navigate what to prioritise, to figure out what is a temporary and what is here to stay. We have to wonder: do software developers have to know about the cloud? If so, why? And most importantly how can we make sure we get the right tools and knowledge that we need in this space?</p><p>Before we answer those questions, lets start from the very beginning.</p><h3><strong>Before Cloud</strong></h3><p>Before we can understand what the cloud is, we need to understand what businesses used before the cloud. That is; Traditional Computing.</p><p>Traditional Computing required businesses to invest in physical infrastructure to store data, digital assets and run complete networking systems for daily operations. Businesses had to run their applications on servers they owned .</p><p>This became a problem because it meant the business had to maintain this infrastructure, ensure that data is backed up and was also soley responsible for securing all this sensitive information. The other problem was that this approach was not scalable and often servers would crash when overloaded with a lot of traffic.</p><p>It was also very expensive to run. Businesses had to predict how much server power they needed, and if they overestimated it came at cost to them. Machines would have to wait idly for traffic, while still running up costs. A lot of money and energy went to waste in these situations.</p><h3>What is the Cloud?</h3><p>The simple definition is that it is the internet — more specifically, it refers to all the resources you can access over the internet. It refers to the servers that run on the internet, and the different software and databases you can run on those servers.</p><p>It makes it possible for us to perform serverless computing, which is a simple approach to microservices. It abstracts the processes of setting up and computing so that you can focus on building. Serverless computing promotes an event based processing system, that does away with the need to have infrastructure idly waiting on activity and instead having that activity trigger functions.</p><p>Okay, now we have a good idea of what the cloud is. This still doesnt answer the <em>why. </em>Why do software developers have to know about the cloud?</p><h3>Do software developers have to know about the cloud?</h3><p>The short answer is yes. The long answer is: the cloud is important to software developers because it is important to the businesses and people we build solutions for. <a href="https://www.cloudzero.com/blog/cloud-computing-statistics#:~:text=51%25%20of%20IT%20spending%20is,%25%20to%2065.9%25%20in%202025.">According to CloudZero</a> 51% of IT spending is moving to the public cloud.</p><blockquote>The public cloud will replace traditional solutions for apps, infrastructure, business process services, and system infrastructure by 2025, compared to 41% in 2022.</blockquote><blockquote>The amount spent on application software will increase from 57.7% to 65.9% in 2025.</blockquote><blockquote>The percentage of cloud-based application software expenditures will rise from 57.7% in 2022 to 65.9% in 2025.</blockquote><p>Those are some big numbers. Software developers should know how the cloud environment is different from the traditional environment. We need to be famaliar with this to be able to know if we can scale and how to scale.</p><p>As software developers, we need to get into the mindset that things will change. Over the years we went from writing html and vanilla javascript to rich and robust frameworks and libraries. Cloud is just one of those tools that have come along that we need to learn. It also doesn’t hurt that there is a lot of money flowing into that space, meaning more opportunities us.</p><h3>Why is industry moving in the direction of cloud?</h3><p>Companies need to ship out features faster than ever. There are several releases every week, every day and these kinds of moves are simply not possible with traditional computing. The cloud simplifies these processes and does this at an affordable rate. It provides business with faster, cheaper and more scalable shipping.</p><p>The up-front cost involved in setting up the cloud is much less than investing in infrastructure to do the same, it is even better because we can pull solutions we are not happy with on demand and immediately cut the costs associated with them. Businesses also really appreciate the predictability and safety of the cloud.</p><h3>What are some good resources to learn more about the cloud?</h3><p>The best place to start is with the very basics. Learn the foundations and fundamentals. Some of the biggest tech companies have made the learning journey easier by offering free resources for eager individuals to learn more about cloud.</p><p><strong>Microsoft </strong>offers <a href="https://eventcatalogppeappservice.azurewebsites.net/en-us/Allevents/?language=English&amp;role=Developers">virtual training days</a> that you can sign up for and after attending, you receive a voucher to write an exam on that subject and get a certification — all for FREE!</p><p><strong>AWS</strong> has a platform called <a href="https://explore.skillbuilder.aws/learn">AWS Skills Builder</a> where they have curated video lessons on cloud technology that makes learning fun with graphics, examples of real world applications and talented indiviuals presenting the courses. It’s actually hard to watch the videos and <em>not</em> learn anything.</p><p>Beyond those basics, there are several platforms that offer courses on Cloud Computing including Udemy, A Cloud Guru, Coursera and <a href="https://www.pluralsight.com/offer/cloud-certification?utm_source=twitter&amp;utm_medium=organic-social&amp;utm_campaign=cloudhappy_2022#certs-section">Pluralsight offers free cloud certification prep courses</a>.</p><h3>What projects are great for beginners in the cloud?</h3><p>Every developer knows that the best way to get better at developing is by building projects to practice those skills. Cloud is no different. Figure out the fundamentals of cloud, and then use that knowledge to build solutions that are both relevant to you and to the industry. Some good ways to practice include:</p><ol><li>Build chatbots similar to the ones found on Discord</li><li>Build an Alexa replica</li><li>Build a university Campus Online Automation</li><li>Build an online book store system</li></ol><p>There are also resoruces online that can guide you in building fantastic cloud projects. <a href="https://cloudresumechallenge.dev/">Cloud Resume Challenge</a> does this by helping you build great projects that you can use to enrich your resume in 16 steps. You can find more project ideas to explore <a href="https://www.projectpro.io/article/cloud-computing-projects-ideas/447">on this website</a> .</p><h3>Conclusion</h3><p>The cloud is inevitable. It is projected that the percentage of cloud-based application software will rise to over 60% by 2025 with the current industries leading in the transition being Retail &amp; Ecommerce, Finance &amp; Banking, and Software Technology.</p><p>No matter your skillset or experience, it is your responsibility as a developer to at least understand the fundamentals of cloud computing and of course, build some projects to get your feet wet. Build things that will show a combination of software skills and serverless tools. Most importantly, have fun in your new learning journey.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5628434c83d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Your First Spring Boot Project With IntelliJ Free Community Addition]]></title>
            <link>https://medium.com/better-programming/build-your-first-spring-boot-project-with-intellij-free-community-addition-44dc950601ef?source=rss-a38a0b11e54b------2</link>
            <guid isPermaLink="false">https://medium.com/p/44dc950601ef</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[intellij-idea]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Moleseng Mokgosi]]></dc:creator>
            <pubDate>Wed, 21 Sep 2022 15:42:34 GMT</pubDate>
            <atom:updated>2022-09-21T18:22:41.038Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build Your First Spring Boot Project With IntelliJ Free Community Edition</h3><h4>A brief introduction to this amazing pairing</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*XtjiQD35ja0DcA9H-JuM-g.png" /><figcaption>Image from <a href="https://dev.to/chincholikarsalil/java-spring-boot-is-there-a-specific-learning-path-2meo">this Salil Chincholikar article</a>.</figcaption></figure><p>You are likely reading because you want to build a Spring Boot application on your IntelliJ IDE. Unfortunately, IntelliJ’s free community addition does not come with a Springboot plugin preinstalled.</p><p>There are a few ways to connect your Java to IntelliJ free addition, and the route we will take in this article will be to create a project on SpringBoot Initialzr and importing.</p><h3>What is Spring Boot?</h3><p><a href="https://spring.io/projects/spring-boot">Spring Boot</a> is an open source Java-based framework built on top of the Spring Framework used to create a micro Service. With the help of Spring Boot, you can then build Rest APIs from your IDE without spending time on complex configurations.</p><h3>What is Java?</h3><p><a href="https://www.oracle.com/java/technologies/">Java</a> is one of the most popular and recognisable programming languages in the world. Java is used to develop mobile apps, web apps, desktop apps, games, and much more.</p><h3>What is Spring Initializr?</h3><p><a href="https://start.spring.io/">Spring Initializr</a> is a web application that can generate a Spring Boot project structure for you.</p><h3>What is IntelliJ?</h3><p><a href="https://www.jetbrains.com/idea/">IntelliJ IDEA</a> is an integrated development environment (IDE) built by JetBrains for JVM languages for developing computer software and designed to maximize developer productivity. IntelliJ IDEA community addition is the free, open source version of this software, and since it is free, it has fewer out-of-the-box functionality than IntelliJ IDEA Ultimate.</p><h3>Prerequisites</h3><p>You should have Java installed on your computer and IntelliJ free community addition IDE downloaded on your computer.</p><h3>Spring Boot Setup</h3><p>Open your command prompt and navigate to the current user’s desktop. When in the file, check that java is installed on your laptop. You will also be able to see which version of Java you are currently on.</p><pre>java --version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*nLyzIgg2LQkYBuRdNE32mQ.png" /><figcaption>Snapshot of Command Prompt</figcaption></figure><p>Next, you can go to your browser and visit <a href="https://start.spring.io/">Spring Initializr</a>. You will see a menu to select the configurations for your Spring project.</p><p>Set up your application as in the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bYFzDzb6euBhN8cqnZ4V1Q.png" /><figcaption>SpringBoot Initializr setup</figcaption></figure><p>Next, go to the dependencies option on the right side of the page and search for “Spring Web.” Add that dependency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*i6oZzb9WLdfG-4KtdqZAUg.png" /><figcaption>Spring dependencies</figcaption></figure><p>Click “GENERATE,” which should download the application onto your computer. The file is zipped, so make sure you unzip it for the next step.</p><h3>IntelliJ Free Community Addition Setup</h3><p>On your computer, open your IntelliJ app and click “Open,” where you will navigate to the Spring Boot project you created above. If you are asked to “Trust and Open Project ‘my-first-springboot-app’?” select Trust Project.</p><p>The project should now be open on your IntelliJ IDE. Navigate to my-first-springboot-app &gt; src &gt; main &gt; java &gt; com &gt; javaguides &gt; springboot &gt; SpringBootFirstApplication. There, you will find the main method. This is the starting point for your app. You will run your application from this file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*08iBAmOIHllnqbJbgGnOvA.png" /><figcaption>Spring Boot project in IntelliJ</figcaption></figure><p>If you run the project at this point and look at the console, it will let you know which localhost portal your application is running. We want to test if everything works as expected. We will do this by building a Rest API endpoint on IntelliJ.</p><h3>Create a Simple Rest API</h3><p>We will create a class in the com.javaguides.springboot package and name it WelcomeController. In the class, we will create a method we will use for our Rest API, but first, we will import RestController and GetMapping (These should automatically import as you call them in your code). Finally, your WelcomeController class will look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1bda76ff60c67042e095d7b309cd865a/href">https://medium.com/media/1bda76ff60c67042e095d7b309cd865a/href</a></iframe><p>Run your program and check your console to ensure it has run successfully. It should tell you which port your application can be found. Go to your browser and navigate to the route you used in GetMapping above (in my case, “/welcome”).</p><p>You will now see the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WxKmUuuMl4DEjYKo8sycag.png" /><figcaption>Final product</figcaption></figure><p>Your Rest API is up and running.</p><h3>Conclusion</h3><p>Congratulations! You have successfully created your first Spring Boot project and built a simple Rest API to test if everything is working as it should. I hope you were as excited as I was to build this and see it work. Spring Boot is a very handy and simple tool to have and explore to create awesome applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44dc950601ef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/build-your-first-spring-boot-project-with-intellij-free-community-addition-44dc950601ef">Build Your First Spring Boot Project With IntelliJ Free Community Addition</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using React Router for Modularization]]></title>
            <link>https://medium.com/better-programming/using-react-router-for-modularization-872b32315a3b?source=rss-a38a0b11e54b------2</link>
            <guid isPermaLink="false">https://medium.com/p/872b32315a3b</guid>
            <category><![CDATA[modularization]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nested-routes]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Moleseng Mokgosi]]></dc:creator>
            <pubDate>Tue, 30 Aug 2022 13:02:10 GMT</pubDate>
            <atom:updated>2022-08-30T13:02:10.070Z</atom:updated>
            <content:encoded><![CDATA[<h4>A brief guide to nested routes</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*gbCeTzc727LZNhGQPXIkHA.png" /><figcaption>image by author</figcaption></figure><p>Sometimes, when building a multipage application, you might have very different features for different pages, or you may want to create different layouts for different parts of your app. This can be achieved by modularization to create different segments of your app.</p><h3>About React-Router</h3><p><a href="https://reactrouter.com/en/main">React-Router</a> is a lightweight client-side and server-side routing library for React. It allows you to handle routing in a web application, displaying different pages depending on the URL. React Router will match the URL and load that particular page’s component. Version 6 will pick the most specific match for a given URL, so you don’t have to worry about ordering your routes.</p><h4>Goal</h4><p>Using React Router to segment an app into different sections.</p><h4>Prerequisites</h4><p>For this tutorial, you must have <a href="https://nodejs.org/en/">Node</a> ≥ 14.0.0 and <a href="https://www.npmjs.com/">npm</a> ≥ 5.6 installed on your computer. You also need to have a general understanding of building and working with reusable components, and you need a code editor. We will also be using <a href="https://styled-components.com/">styled-components</a>, which is a library that allows you to write CSS directly inside your JS file. This eliminates the need to move back and forth between different files to style a component.</p><p>Let’s get into it.</p><h3>Set Up</h3><p>We will start by creating a new React application by running this command on your terminal or cmd:</p><pre>npx create-react-app my-router-app</pre><p>Navigate into your application and then install the react-router-dom package and the styled-components package. The @6 at the end of the command means you’re adding version 6 of react-router-dom.</p><pre>cd my-router-app<br>npm install react-router-dom@6 --save styled-components</pre><p>Your package.json file should look similar to this:</p><pre>&quot;dependencies&quot;: {<br>  &quot;@testing-library/jest-dom&quot;: &quot;^5.16.5&quot;,<br>  &quot;@testing-library/react&quot;: &quot;^13.3.0&quot;,<br>  &quot;@testing-library/user-event&quot;: &quot;^13.5.0&quot;,<br>  &quot;react&quot;: &quot;^18.2.0&quot;,<br>  &quot;react-dom&quot;: &quot;^18.2.0&quot;,<br>  &quot;react-router-dom&quot;: &quot;^6.3.0&quot;,<br>  &quot;react-scripts&quot;: &quot;5.0.1&quot;,<br>  &quot;styled-components&quot;: &quot;^5.3.5&quot;,<br>  &quot;web-vitals&quot;: &quot;^2.1.4&quot;<br>},</pre><p>Once the setup is complete, you can run the command npm start in your app’s folder to launch. You can now see the default React application when you open port 3000 on your localhost.</p><h3>Create Pages and Components</h3><p>Everything we create in this section is technically a component, but some of the components will serve as pages while others will be rendered as part of pages.</p><p>We start by creating a pages directory inside the src folder. This is where all our pages will go. And also, in our src folder, we create a components directory where we will put the other components that make up our pages.</p><p>We will build a LoginPage, a HomePage, a CollectionsPage, and a FavouritesPage. We will also use styled-components to add very simple styles to our components.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/94e297f499d7f000499c7cd35d0131b3/href">https://medium.com/media/94e297f499d7f000499c7cd35d0131b3/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea2ad0d374cf00b3ac799b63ca65503c/href">https://medium.com/media/ea2ad0d374cf00b3ac799b63ca65503c/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f83a5c52c51f1fb91a027612e251ce22/href">https://medium.com/media/f83a5c52c51f1fb91a027612e251ce22/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c925ab27d9bab1a49f203eb7961ebf9/href">https://medium.com/media/9c925ab27d9bab1a49f203eb7961ebf9/href</a></iframe><p>Next, we create the Footer component.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c9a6778fa4d0ea1eba69825df5ad3d6/href">https://medium.com/media/4c9a6778fa4d0ea1eba69825df5ad3d6/href</a></iframe><p>We will be creating the Navbar component in the next step.</p><h3>Utilizing Nested Routes To Segment Your App</h3><p>Nested routes are one of the strongest features offered by React Router. According to the React Router <a href="https://reactrouter.com/en/main/getting-started/overview#nested-routes">documentation</a>:</p><blockquote>Routes can be nested inside one another, and their paths will nest too (child inheriting the parent)</blockquote><p><a href="https://dev.to/tywenk/how-to-use-nested-routes-in-react-router-6-4jhd">Here</a> is a good article that goes deeper into how nested routes can be utilized to create complex layouts.</p><p>In our case, we will use the nested routes concept to render the Navbar and Footer components conditionally.</p><p>We start by creating a new component in our components folder, which we will name MainLaoyout.js . In this component, we will import all components with a similar layout and the components appearing on multiple components. The Navbarand Footercomponents will be rendered in the HomePage , CollectionsPage and FavouritesPage.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac3e5a1fc0833371df3c0c7eb52dfeae/href">https://medium.com/media/ac3e5a1fc0833371df3c0c7eb52dfeae/href</a></iframe><p>As you can see from the above, to render a component on multiple pages, you have to place that component outside of the Routes tag that contains said components. The Routes tag is the parent of the Route tag, where each Route tag will contain each page that can be navigated to. This way, the Navbar and Footer components will appear on all the pages described within the Routes tag.</p><p>Next, we create the Navbar component. This component will contain links to all the other pages in our app.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ffd55d4715a5730b7fa113d809c921a9/href">https://medium.com/media/ffd55d4715a5730b7fa113d809c921a9/href</a></iframe><p>Finally, in our App.js component, we put the different parts together to complete our application.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/61984c4c07302d2e398ffb8aaf4dd937/href">https://medium.com/media/61984c4c07302d2e398ffb8aaf4dd937/href</a></iframe><p>At the end of this final step, you should have a home page with a navbar and footer. When you navigate through the pages, you should see the nav and footer are persistent, and when you click on the ‘Logout’ option, you will see the nav and footer are no longer there.</p><h3>Conclusion</h3><p>In this article, we used nested routes to create a modularization. Our application only had two areas, but you can use this concept to create even more areas.</p><p>And finally, <a href="https://stackoverflow.com/a/71446125">note</a> that each child component in the Routes tag must be a Route component. This is why, in the MainLayout component we used React.Fragment , so that when we render it from the App.js component, it is surrounded by a Route tag.</p><p>I hope you found this article helpful!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=872b32315a3b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/using-react-router-for-modularization-872b32315a3b">Using React Router for Modularization</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating a Create-React-App to NextJS]]></title>
            <link>https://medium.com/better-programming/migrating-a-complete-creat-react-app-to-nextjs-ba6edd8e64f1?source=rss-a38a0b11e54b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba6edd8e64f1</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Moleseng Mokgosi]]></dc:creator>
            <pubDate>Wed, 06 Jul 2022 15:09:30 GMT</pubDate>
            <atom:updated>2022-07-07T12:49:42.994Z</atom:updated>
            <content:encoded><![CDATA[<h4>And know the subtle differences between the two frameworks</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z1U7SJeqK_JJXUYei5uD8w.png" /><figcaption>Image from<a href="https://github.com/ijsto/reactnextjssnippets"> ijsto</a></figcaption></figure><p>I recently started building a web app for a salon, that would include a booking system. I wanted to design this in such a way that it would be easy for the user to navigate through the app, so I want to have a home page that would be the starting point of the application that would have all the information about the salon and then have one other page that would handle the booking system.</p><p>I started and coded the complete home page with CRA, and soon realised I have to move it to Next.js. Unfortunately, I could not find help for my exact issue as I had to change most of my functionalities so they work on Next. The following article is a step-by-step guide on how to move a complete CRA to Next.js along with some of the resources that helped me along the way throughout the article.</p><h4>About Create-React-App</h4><p>React is a library that is used to create interactive user interfaces by building reusable components. Create-react-app is the quickest and easier way to build a single-page application in React. It sets up your development environment, so you spend less time worrying about the nitty gritty, and more time creating a beautiful interface.</p><h4>About NextJS</h4><p>Next.js is a React framework makes it easier for you to build efficient web applications. It makes it possible for you to move from a single-page application to a content rich application that you can navigate through by simplifying the process of creating routes. It also increases performance of your application by making use of the concept of on-demand rendering rather than build-time rendering.</p><h4>Goal</h4><p>To migrate a full SPA with all it’s components and styles made with Create React App to Next.js.</p><h4>Prerequisites</h4><p>This article is about Next.js which is a React framework. You should be knowledgeable with web development, React.js library and partial knowledge of Next.js is necessary.</p><p>This articles assumes you have already created the React app and have either completed the single-page application or have already built the necessary components and styles and all you need now is to transition your project to Next.js.</p><h4>About the Project</h4><p>We will be moving a single-page React App along with its components and styles to a Next.js. This will require us to change the file structure.</p><h3>Table of Content</h3><ul><li>Create-React-App Project File Structure</li><li>Installing NextJS</li><li>Configuring Your Application</li><li>NextJS Project File Structure</li></ul><h3>Create React App File Structure</h3><p>Create React App contains three main folders:</p><ol><li>the node modules folder. This folder is created during compiling when you run the “create-react-app” command.</li><li>the public folder. This folder contains the index.html file, which is the entry point of the application. The images folder in the public folder is optional. Some developers advise that it is best to place your image next to the <a href="https://bobbyhadz.com/blog/react-where-to-put-images">component where it will be used</a>.</li><li>the last folder is the src folder. This folder will have the components you have built for your app, your css files as well as the App.js file and the index.js file. Additionally, your src file will have your package.json file, which is very important piece for your project.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*FpaiaPRBNzlKDNfAQB8Obg.png" /><figcaption>CRA File Structure</figcaption></figure><h3>Installing NextJS</h3><h4>Step 1 — Uninstall React Scripts</h4><p>We will start by removing the react scripts. Go to your terminal add this command, which will uninstall the react-script dependencies.</p><pre>npm uninstall react-scripts</pre><h4>Step 2 — Install Next package</h4><pre>npm install next</pre><p>When the Next package has installed, check your main project directory for the .next folder. If it isn’t there, you can add it yourself (I used a .next folder from the create-next-app tutorial. Just copy it and paste it tp your main folder).</p><h4>Step 3 — Change the scripts in the package.json file to Next scripts</h4><p>Your scripts should go from this:</p><pre>&quot;scripts&quot;: {<br>   &quot;start&quot;: &quot;react-scripts start&quot;,<br>   &quot;build&quot;: &quot;react-scripts build&quot;,<br>   &quot;test&quot;: &quot;react-scripts test&quot;,<br>   &quot;eject&quot;: &quot;react-scripts eject&quot;<br>}</pre><p>to this:</p><pre>&quot;scripts&quot;: {<br>   &quot;dev&quot;: &quot;next dev&quot;,<br>   &quot;build&quot;: &quot;next build&quot;,<br>   &quot;start&quot;: &quot;next start&quot;<br>}</pre><p>and your dependencies should look like this:</p><pre>&quot;dependencies&quot;: {<br>   &quot;@testing-library/jest-dom&quot;: &quot;^5.16.4&quot;,<br>   &quot;@testing-library/react&quot;: &quot;^13.3.0&quot;,<br>   &quot;@testing-library/user-event&quot;: &quot;^13.5.0&quot;,<br>   &quot;next&quot;: &quot;^12.2.0&quot;<br>   &quot;react&quot;: &quot;^18.2.0&quot;,<br>   &quot;react-dom&quot;: &quot;^18.2.0&quot;,<br>   &quot;web-vitals&quot;: &quot;^2.1.4&quot;<br>}</pre><h3>Configuring your application</h3><p>Now that you have all the depencies and scripts for Next to work with your project, the next step is to set up your file structure for Next. Next.js does not work in the same way that React does. Where the entry point for a React application is the index.html file, Next does not have any index.html files.</p><p>The very first thing you need to do in this section is create a “pages” folder in your main application folder.</p><h4>Compiled Output</h4><p>The equivalent of the index.html file in NextJS is the <a href="https://nextjs.org/docs/advanced-features/custom-document"><em>_</em></a><a href="https://nextjs.org/docs/advanced-features/custom-document">document.js</a> file.</p><blockquote>A custom <em>Document</em> can update the <em>&lt;html&gt;</em> and <em>&lt;body&gt;</em> tags used to render a <a href="https://nextjs.org/docs/basic-features/pages">Page</a>. This file is only rendered on the server, so event handlers like <em>onClick</em> cannot be used in <em>_document</em> .</blockquote><h4>Step 1 — Create _document.js file</h4><p>In your “pages” folder, create a new file and name it _document.js<em> .</em> Your file should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cdbcc4c2184c97ce839102a9d268f68/href">https://medium.com/media/7cdbcc4c2184c97ce839102a9d268f68/href</a></iframe><p>and then to override the default Documenttake everything you have in the head section of your index.html<em> </em>file and paste it in the head section of the_document.js<em> </em>file. This would be a good place your Google Fonts links and your Fontawesome links if you have any, the end product wil look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/681a6ab5d4848c6d7aa3693de006895f/href">https://medium.com/media/681a6ab5d4848c6d7aa3693de006895f/href</a></iframe><p>For more information about how to incorporate &lt;Title&gt; and &lt;Head&gt; tags on in your project, <a href="https://www.techomoro.com/how-to-add-title-and-meta-tags-for-each-page-in-next-js/">visit this article</a> .</p><h4>Step 2 — Create a _app.js file</h4><blockquote>Any shared layout between all pages should be moved to a <a href="https://nextjs.org/docs/advanced-features/custom-app">custom </a><a href="https://nextjs.org/docs/advanced-features/custom-app"><em>_app.js</em></a>.</blockquote><p>The pages folder is where you will place the <a href="https://nextjs.org/docs/advanced-features/custom-app">_app.js</a><em> </em>file. And if you want meta tags or components (for example a navigation bar and a footer)that will be applied to all the pages, place them in this file.</p><p>We start by importing the Head component from next/head</p><pre>import Head from &#39;next/head&#39;;</pre><p>Place your meta tags in the &lt;Head&gt; tag:</p><pre>&lt;Head&gt;<br>  &lt;meta charset=&quot;utf-8&quot; /&gt;<br>  &lt;meta name=&quot;author&quot; content=&quot;Moleseng&quot; /&gt;<br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot; /&gt;<br>&lt;/Head&gt;</pre><p>in the end, your _app component will look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9bc64ccc6064be626874cdb7b9ddc45/href">https://medium.com/media/f9bc64ccc6064be626874cdb7b9ddc45/href</a></iframe><h4>Step 3 — Components and pages</h4><p>Now we have arrived at the most interesting part of this process; setting up our components that we made in the React app so we can render them in our Next app. NextJS does not house its components in a src folder, and rather it has two main folders for this, namely; the components folder and the pages folder.</p><blockquote>In Next.js, a <strong>page</strong> is a <a href="https://reactjs.org/docs/components-and-props.html">React Component</a> exported from a <em>.js</em>, <em>.jsx</em>, <em>.ts</em>, or <em>.tsx</em> file in the <em>pages</em> directory. Each page is associated with a route based on its file name.</blockquote><p>find out more about this <a href="https://nextjs.org/docs/basic-features/pages">here</a>.</p><p>So in our pages folder, we will create an index.js file. The index.js will contain the home page, which will be the first page your user sees when they open your web app. Here, you can liThe rest of the pages folder will contain all the other pages you’ve made available for your user to visit. It would look something like this:</p><pre>export default function HomePage() {<br>  return (<br>    &lt;div&gt;<br>      Hello, this is HomePage!<br>    &lt;/div&gt;<br>  )<br>}</pre><p>You can also add a &lt;title&gt; tag if you want the title to be something unique. This is something you can do for each the pages of your app and one of the cool touches I really like from NextJS:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23910ba490bb33a64b446b6789a847a0/href">https://medium.com/media/23910ba490bb33a64b446b6789a847a0/href</a></iframe><p>The next folder you will create in your main project directory is the components folder. This folder will hold all the reusable components that make up different parts of your application, just like you would have in your React app, only this time it does not fall in the src folder. This components can be imported into whichever other component or page that you want to use them in.</p><h4>Styling</h4><p>Next.js allows you to import styles into your app just like React, but instead it will require these files to be CSS Modules instead. You can read more about it <a href="https://nextjs.org/docs/basic-features/built-in-css-support">here</a>.</p><p>You will start by creating styles folder in your main project directory. Next, take all the style files you have from your original React project and move them ino the styles folder. The next stem is to rename the files, for example if you have styling for your navigation bar, it will go from navbar.css to navbar.module.css . Importing the style into your component and using it will look like this:</p><pre>import styles from &#39;../styles/about.module.css&#39;;</pre><pre>export default function Navbar(){<br>   return (<br>      &lt;&gt;<br>       &lt;h1 className={styles.heading}&gt;This is the Navbar&lt;/h1&gt;<br>      &lt;/&gt;<br>   )<br>}</pre><p>As you can see above, to use the styling you have to first import it using a variable name for it and when using it in your tag, use the dot notation starting with the name of the variable and then target the styling property from your module.css file.</p><h4>Images</h4><p>Next.js uses the public folder to store all the images from your application and a Image component for image files. This is for image optimization purposes.</p><p>To use this component, your first import it into the component you will be using it in:</p><pre>import Image from &#39;next/image&#39;;</pre><p>Next, you will want to use the image in your component and the final product will look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2cb1c0252d97bfec471f9fa9d974295/href">https://medium.com/media/d2cb1c0252d97bfec471f9fa9d974295/href</a></iframe><p>As you can see above, the image component’s width and height attributes do not receive px strings for sizing, instead take they take exact values. This is something you will have to change from your original React application and play around with the values to get the sizing right. <a href="https://nextjs.org/docs/api-reference/next/image">Here</a> is where you can get more information about the Image component and its attrubutes.</p><h3>Next.js Project File Structure</h3><p>After making all the changes we went through above, your project directory should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*BO2Z3bHMWBQAdBAYi8p4JA.png" /><figcaption>Next.js Project File Structure</figcaption></figure><p>At this point, you can now add more pages to your application that your users can be directed to by adding to your project. You can read more about it <a href="https://nextjs.org/docs/api-reference/next/link">here</a>.</p><p>You should be having a running application now and you can see if it works on your local host by running the following command on your terminal:</p><pre>npm run dev</pre><h3>Conclusion</h3><p>As you have seen above, migrating a complete CRA to Next.js is not very difficult to do. Just remember the following:</p><ul><li>The index.html equivalent for Next.js is the _document.js file.</li><li>Next.js does not make use of the src folder. Your component folder will be inside your main project directory.</li><li>Next.js uses modules to for style application and your styles are imported with a variable name that will be used to access style properties to your elements.</li><li>Next.js uses the Image component to render your image files optimally and on-demand rather than on build time.</li><li>The Next.js project’s main project directory file structure is more concise than the CRA project file.</li></ul><p>I hope you found this article helpful! Thanks for reading!</p><pre><strong>Want to Connect?</strong></pre><pre>If you have any questions or suggestions, please reach out to me on <a href="https://www.linkedin.com/in/moleseng-mokgosi-ab506b11b/">LinkedIn</a>.</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba6edd8e64f1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/migrating-a-complete-creat-react-app-to-nextjs-ba6edd8e64f1">Migrating a Create-React-App to NextJS</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>