
Over the past few years, Netlify has easily worked its way into the hearts and minds of many developers. Some developers consider Netlify to be the best thing that’s ever happened to them when it comes to software development and deployment.
Netlify prides itself on being the fastest way to build amazing sites. It can be a serious boon to your productivity. Netlify has a popular tagline that can serve as an anchor for this tutorial:
“Just git push to deploy worldwide.”
Prerequisites
The goal here is to take an in-depth look at deploying React apps using Netlify. To follow along with this tutorial, you’ll need a working knowledge of the following:
What does Netlify have to offer?
Aside from the fact that most of its features are absolutely free, Netlify also eases deployments by providing the following:
- An easy to use UI
- Deployment within seconds
- Rolling updates, which means no downtime even during updates to site
- Rollbacks to previous working versions of your site
- Continuous integration and continuous deployment from version control
- Instant forms for collating user data
- Netlify functions for serverless operations, etc.
Preparing the React application for deployment
There are three major ways for deploying applications to Netlify that we’ll be highlighting today.
Before we dive into the specifics of each method, let’s touch on some generic steps that apply across all the different deployment methods.
Creating a React app
React is an open source frontend JavaScript library for building user interfaces and UI components.To get started creating a React app, we’ll use the create-react-app
library to create an app called test-netlify-deployment
.
In the terminal, we’ll run the following command:
npm install -g create-react-app create-react-app test-netlify-deployment cd test-netlify-deployment
The above command installs all the packages required to create a simple React application alongside some static files, thereby giving us a base to work with.
For this tutorial, we’ll be deploying this sample app as is. Please feel free to make as many changes as you want to your sample application.
Create a build directory
Next, we’ll want to create a build of our application in a production-ready build folder.
To accomplish this, let’s run the command below:
npm run build
This command generates a build folder that represents a minified version of the entire application, containing everything we would need to deploy the application.
Now that we have our React app ready to be deployed, we can push this app to our version control of choice. In this case, we’ll choose Github.
Version control with Github
There are so many version control systems out there, but for the sake of this tutorial, we’ll focus on the Github version control system. Follow the guide here to get started with Github.
We’ll create a Github repository with any name we want. Then, we’ll push our React app to the Github repo as shown in the image below. You can find my sample repo here.
Once we are done with this, we can dive deep into the different methods for deploying our app to Netlify.
3 methods for deploying React applications to Netlify
Method 1: Netlify UI
This method is best suited for developers who would rather deploy and configure applications manually using the Netlify user interface rather than using the command line terminal.
Connect Netlify account with Github account
If you do not have a Netlify account already, you can create a free one here.
We’re going to log into Netlify with our already created Github account and follow the prompts to authorize Netlify Auth:
After authorizing Netlify Auth, we are redirected to our Github teams page. Next, we’ll need to create a New Site from Git, as shown below:
Authorize Netlify to access repositories
Still on the create a new site
page, we would be prompted to authorize Netlify to access the Github repositories. We can choose to give Netlify access to the entire Github account, or we can give Netlify access to a specific repository by clicking on the “Configure Netlify on GitHub” button at the bottom of the page.
Build options & deploy
After selecting the repository where the React application is hosted and choosing the deployment branch from the step above, we specify the basic build settings required to deploy the site.
Although this page comes pre-populated with the build step, please check that it conforms with the command that builds your application.
Once this is done, we click on the good ol’ button Deploy Site
, and Voila! We’ll see the site deployment in progress.
Upon successful deployment, we can preview our site with the test domain it returns.
Configuring site domain
Once we have previewed our React app deployment and feel good about how it looks, we can now configure a proper domain to serve our application. In the Deploys tab, we see details of site deployment. That’s where we register the subdomain we would like to use for our React application.
If we want to use a preregistered domain, Netlify will want us to verify that the domain is ours. We’ll click on set up a custom domain
from the image above. This prompts us to verify our custom domain before Netlify can configure it.
Once this is successfully verified, we can access our application on the configured domain.
Netlify drag and drop
This method is pretty similar to the first method described above. However, the drag and drop feature is unique in that it utilizes the online app feature. It is specifically suited for super fast deployments.
Log in to your Netlify account
We can follow the first step of the first method above to connect our Github account to our Netlify account. However, we’ll see that in this instance we are greeted with a blank page as shown below. This is what we refer to as the online app feature.
We will not be creating a new site from git like we did in the first method.
Drag and drop
It’s that easy!
Since we have our React app with an up-to-date build
folder, all we have to do is drag the build folder into the blank space above. This black space is otherwise known as the online app. Netlify does the deployment magic for us.
Configuring site domain
This follows the same approach as configuring the site domain in the first method described above.
Netlify CLI
This method is for developers who are more comfortable running deployments from the command line terminal as opposed to using the UI or the drag and drop feature
Install Netlify CLI
Installing the Netlify CLI is very quick and easy. It’s as easy as running an npm install
command as shown below:
npm install netlify-cli -g
Authorize CLI
After installing the CLI, we navigate into our working directory and run the following commands to authorize our Netlify CLI against the Netlify account:
cd test-netlify-deployment netlify deploy
Note: Ensure that pop-up is not blocked in the browser window for redirects.
Running the Netlify deploy command will redirect us to a browser window requesting authorization for the Netlify CLI:
Deploy application
Now that the CLI has adequate permissions to access the Netlify account, we can go ahead and deploy the application.
There are a few command line prompts that we’ll want to go through together. We can navigate the prompts by using the arrow keys on your device.
CLI prompt 1: This folder isn’t linked to a site yet. What would you like to do?
This is the first prompt after authorizing the app. It wants to know if we want to deploy this application to a pre-existing site, or to a new site. In this case, we are deploying to a new site, so we select “Create & configure a new site”.
CLI prompt 2: Choose a site name (optional)
We could decide to configure the site details from here, or leave it blank so that Netlify gives us a random name. Regardless of the option you go with here, you can always update it later.
From the image above, we can see how Netlify beautifully generates a custom domain URL from the site name.
However, even though we have a url, we are not done with the deployment just yet.
CLI prompt 3: Deploy path
Since we are running the netlify deploy
command in our React app working directory, our deployment path is our build folder. As a result, we’ll just need to specify the path to our build directory in response to the prompt.
This is necessary, as only the build folder contains the production-ready files needed to deploy the application.
Now we have a URL we can test with.
Note: If the URL redirects to a webpage that throws a Page Not found error, this is an issue that has to do with an incorrect build file. Please run the netlify deploy
command again and update the build file accordingly.
“If everything looks good on your draft URL, deploy it to your main site URL with the
--prod
flag”
Deploy application to production
After testing with the website draft URL, we take our application live by running the command from our output above:
netlify deploy --prod
Once again, we would be required to specify the deploy path, which is the path to our build directory. After successful deployment, we get an updated website URL.
Two important things to note are the Unique deploy URL and the live URL, as shown above.
The Unique deploy URL
represents the URL specific to each deployment.
The Live URL
is the production website URL.
We can now access our React application from the Live URL.
Conclusion
Deploying React apps and other applications with Netlify is a seamless process, owing largely to the platform’s easy to use features.
Once the preferred deployment method is chosen and the requirements are met (e.g installing the CLI, if CLI is our preferred method), you can typically deploy your app to Netlify in under 60 seconds, all things being equal.
I hope you enjoyed creating and deploying a React application with me. Do let me know in the comment section.
Full visibility into production React apps
Debugging React applications can be difficult, especially when users experience issues that are difficult to reproduce. If you’re interested in monitoring and tracking Redux state, automatically surfacing JavaScript errors, and tracking slow network requests and component load time, try LogRocket.
LogRocket is like a DVR for web apps, recording literally everything that happens on your React app. Instead of guessing why problems happen, you can aggregate and report on what state your application was in when an issue occurred. LogRocket also monitors your app’s performance, reporting with metrics like client CPU load, client memory usage, and more.
The LogRocket Redux middleware package adds an extra layer of visibility into your user sessions. LogRocket logs all actions and state from your Redux stores.
Modernize how you debug your React apps — start monitoring for free.
[url=http://remviagra.com/]sildenafil uk pharmacy[/url]
[url=http://viagralevitracialis.com/]average cost viagra[/url] [url=http://ibbmeds.com/]minocycline capsule 100mg[/url] [url=http://znpharmacy.com/]online pharmacy bc[/url] [url=http://eleventabs.com/]digoxin[/url] [url=http://tadalafilpack.com/]cost for cialis for daily use[/url]
[url=http://ozzpills.com/]zanaflex 4mg tablet price[/url] [url=http://remviagra.com/]how to buy viagra over the counter[/url] [url=http://coopills.com/]cleocin cream price[/url] [url=http://realcialis.com/]cialis 2.5 coupon[/url] [url=http://tadalafilfive.com/]generic cialis black[/url]
[url=https://vnplending.com/]personal loan eligibility[/url] [url=https://jnlending.com/]signature loans[/url] [url=https://paydayover.com/]micro credit[/url] [url=https://loanslm.com/]credit card loan[/url] [url=https://paydaylo.com/]loan source[/url] [url=https://kashadvance.com/]advance payday loan[/url] [url=https://awaloans.com/]3 month loans[/url] [url=https://conloans.com/]best debt consolidation loans[/url]
[url=https://tabviagra.com/]female viagra south africa[/url] [url=https://pharmadop.com/]lamisil tablets over the counter[/url] [url=https://medbuyp.com/]yasmin price usa[/url] [url=https://viagramru.com/]can i buy viagra in usa[/url] [url=https://tadalafilbrm.com/]cialis canada no prescription[/url]
[url=http://atalending.com/]no verification loans[/url]
[url=http://viagraofp.com/]sildenafil 100mg for sale[/url] [url=http://remviagra.com/]best viagra over the counter[/url] [url=http://dexamethasonetabs.com/]dexamethasone 6 mg[/url] [url=http://ozzpills.com/]tizanidine 2mg tablet price[/url] [url=http://viagratrp.com/]buy sildenafil 200mg[/url] [url=http://tadalafiltry.com/]online cialis in canada[/url] [url=http://ivermectinlab.com/]ivermectin 0.5 lotion[/url] [url=http://sildenafilon.com/]order viagra pills online[/url] [url=http://sildenafilpoi.com/]viagra generic[/url] [url=http://viagrastab.com/]viagra pharmacy india[/url]
[url=http://loanspdi.com/]loans for bad credit with monthly payments[/url]
[url=http://onnpharmacy.com/]canadian prescription pharmacy[/url] [url=http://tadalafilfive.com/]buy real cialis cheap[/url] [url=http://coopills.com/]cleocin for acne[/url] [url=http://ivermectinchem.com/]stromectol for humans[/url] [url=http://ozzpills.com/]triamterene weight loss[/url]
[url=https://sildenafil69.com/]order sildenafil india[/url]
[url=https://conloans.com/]1500 payday loan[/url]
[url=http://cialispale.com/]genuine cialis for sale[/url]
[url=http://awaloans.com/]cash lenders[/url] [url=http://jnlending.com/]america loan[/url] [url=http://psiloans.com/]direct cash[/url] [url=http://astiloans.com/]short term[/url] [url=http://cashadvi.com/]paydayloans[/url] [url=http://paydaylo.com/]no credit check lenders[/url] [url=http://ettaloans.com/]pay day loans near me[/url]
[url=http://loanslm.com/]no fax payday loans[/url]
[url=http://tadalafilbrm.com/]can you buy cialis in canada over the counter[/url]
[url=http://loanslm.com/]payday loans online same day[/url]
viagra without a prescription http://viagrastm.online/ viagra online canada
[url=https://cialisneo.com/]cialis 5 mg cost[/url]
[url=http://tadalafilfive.com/]generic cialis price[/url]
[url=https://loanslm.com/]ace cash express[/url] [url=https://cashaddv.com/]short term installment loan[/url] [url=https://ettaloans.com/]payday loan instant approval[/url] [url=https://loanspdi.com/]nevada payday loans[/url] [url=https://cashadvi.com/]best debt consolidation loans[/url] [url=https://astiloans.com/]unsubsidized loan[/url]
[url=http://cashadvi.com/]tribal loans guaranteed approval[/url]
[url=http://sildenafilon.com/]how can you get viagra over the counter[/url]
[url=https://awaloans.com/]get a loan[/url] [url=https://astiloans.com/]easy payday[/url] [url=https://paydaytwo.com/]cash advance[/url] [url=https://vedaloans.com/]where to get a loan[/url] [url=https://ettaloans.com/]consolidation loans for fair credit[/url] [url=https://atalending.com/]loans overnight[/url] [url=https://lialoans.com/]loans no credit check lenders[/url] [url=https://paydaylo.com/]loans 2019[/url]
[url=http://tadalafilpack.com/]cialis without rx[/url]
[url=https://paydayover.com/]personal loans with no collateral[/url]
[url=http://awaloans.com/]loan emi[/url] [url=http://conloans.com/]fax payday loan[/url] [url=http://ettaloans.com/]nevada payday loan[/url] [url=http://atalending.com/]payday 2 wiki[/url] [url=http://paydayover.com/]short term loans no credit check[/url] [url=http://psiloans.com/]cash advance loan[/url] [url=http://jnlending.com/]simple loan[/url]
online pharmacy without scripts uk pharmacy best ed pills
specialty pharmacy tops pharmacy rx pharmacy online
pharmacy online mexican pharmacy cheap rx
the pharmacy pharma rx pharmacy coupons
usa pharmacy best drugstore shampoo best drugstore setting spray
buy generic viagra blog
cialis price in mexico
generic viagra italy paple Beimb
viagra coupon from pfizer
cialis online purchase canada
cialis from india generic paple Beimb
cialis sale paypal
tadalista soft 40
is there an expiration date on viagra pills paple Beimb
cialis 28 cpr 5 mg prezzo
tadalafil daily 5mg
rite aid levitra price paple Beimb
kjhd viagra over the counter usa 2020 http://dietkannur.org ntgm yljc
female cialis cialis for low price cialis daily pricing [url=http://mycialedst.com/]rx party cialis[/url] ’
finpecia uk buy
viagra hearing loss
over the counter viagra substitutes paple Beimb
cialis kaufen paypal bezahlen
buying viagra over internet
buy alesse 21 online paple Beimb
viagra without priscription cheap viagra does insurance cover viagra [url=http://llviabest.com/]viagra buy[/url] ’
online cialis canada buy cialis pay pal cialis and viagra [url=http://phrcialiled.com/]cialis in uk[/url] ’
100 mg cialis cialis from india cialis for women side effects [url=http://21cialismen.com/]viagra/cialis black and gold 800[/url] ’
discount viagra cheapviagrathatacceptsmastercard buying viagra with next day shipping [url=http://genqpviag.com/]brand viagra[/url] ’
generic viagra for sale buy viagra very cheap
viagra online .au buy brand viagra cheap viagra [url=http://acialaarx.com/]viagra 25mg vs 50mg[/url] ’
5mg cialis cialis, 20 mg, canadian cialis from canada [url=http://cialijomen.com/]cialis generic cipla[/url] ’
viagra dubai online authentic viagra viagra for sale in australia [url=http://genericrxxx.com/]how much does viagra cost with insurance[/url] ’
buy medication without an rx viagra only 0.2$
where to buy genuine cialis online
tinder online , tinder website https://tinderdatingsiteus.com/
costa rica cialis sale 24 hour pharmacy buy cialis united states [url=https://xz-pharmacyonline.com]Caverta[/url] ’
generic cialis cheap canada
discount cialis no prescription
buy cialis cialis for cheap sell of cialis [url=http://loncialis.com/]black cialis sale[/url] ’
Your objective must be to enjoy betting and not to make it your source of income.
sildenafil citrate sublingual: usa over the counter sildenafil – sildenafil 1 cream
viagra in pakistan street value of viagra viagra 50 mg [url=https://canadianpharmacy-usx.com/organic.htm]does alcohol inhibit viagra[/url] ’