You can easily create a website with HTML, CSS and some JS. But here we learn how to create a simple React website and bring it to life in just 5 minutes with Firebase hosting.
I believe you have a basic knowledge of the reaction and the basis of the fire. Otherwise, please refer to the official React website and the Firebase hosting documentation.
Creating a website with answer
Rect.js is one of the best libraries for creating one-page web applications. In addition to pages, you also react with components. To make a few pages in the React application, we actually use a number of resources. That means the road is one way.
To learn more about React, please read the article What are the benefits of using React.Js for web development?
Here we will use React to create a simple one page website. Please note that I am not interested in creating a complete website with attractive pages and links, as this article is about the release of React with Firebase.
1. Creating a JetApplication
You must first create a reactive application with the NPX tool. Don’t worry about NPX because it is a tool that comes with NPM (Node Package Manager) 5.2+ and above.
So, after successfully installing Node.js, create a React application with NPX.
simple npx creatures website
This command creates a reactive application called a single-website project.
Now enter the project folder and start the application.
easy to use CD
n/min Boot up
A browser window opens the React application we created with the address https://localhost:3000. The port may look different when 3000 people are in use.
If you need extra help installing React on your system, you can use the links below.
Answer questions about Windows, Ubuntu, and MacOS
2. Add Bootstrap CDN
We use the bootstrap model to customize our display, and this requires a CSS bootstrap file. There are several ways we can add a bootstrap to our reactive application, which is why I use the CDN Bootstrap.
So open the index.html file in the shared folder and add the Insider CDN boot file.
So the complete index.html file looks like the one below.
3. Home page design
In concrete cases, the React sites are divided into components and all components are imported into the App.js.
But here, I don’t want to make this site so complex. So I’m going to code the design of my homepage into the App.js file.
So the complete application we have prepared is as follows.
4. Construction of production buildings
So I created a simple response website. Please note, however, that the current version of this site is under development. We need to make a production-ready version for the hosting.
Run the following command to have the version ready for production
Production per minute
In this case, a directory named build is created in the root of the project. We can install this file on Firebase.
Host website created in Firebasedatabase
You may have heard of the fire brigade base. It’s Google’s mobile and web application development platform that helps you create, improve and develop your applications.
We can use all their services free of charge up to the border. Here we put our website in Firebase for free.
1. Setting up a project in the database of Firebase
First set up a project at Firebase via the link below.
Click on the button Add project and fill in the form with the name of your project. Click on the button Create project.
If all goes well, a success message will appear as shown below.
Now go from the side menu to the Hosting section and press the start button. This shows the modal as shown below.
It shows the instructions for installing fire extinguishers in our system. This can easily be done with the NPM. We already have Node.js and NPM installed in our system. Now install the Firebase tools with the following command.
plants npm -g refractory tools
Now press the Next button. Here you can see different commands that have to be executed. They are explained in the following paragraphs.
2. Sign in to your Google Account
Sign in to your Google Account with the following command
This requires your permission, as indicated below.
Do you allow Firebase to collect anonymous information about CLI usage and error messages?
Come on in, yeah.
Provide access to your Google Account.
Then a success message appears in our system.
3. Initialisation of the firebase in our project
Initialize Firebase in our project with the following command.
Now he’s asking some questions.
- Which CLI Firebase functions do you want to configure for this folder? Press the spacebar
to select the functions, then press the Enter key to confirm.
Select the option Hosting.
2. Select the default Firebase project for this folder.
Select the project we previously created on Firebase (example website).
4. Project execution
The deployment of a project on Firebase can be done with just one command. But by default Firebase only delivers the public folder in our project. In our case, we need to expand the build directory, so change the firebase.json file.
public: create, ignore
Now enter your project with the following command.
If all goes well, you’ll see a complete Deploy message and the hosting URL. In my case the hosting URL is shown below.
Hosting URL: https://sample-website-133.firebaseapp.com
We can now connect the domain name (if we have one).
If you don’t have a domain name, buy one from a domain name registrar. The URL below will help you purchase a domain name from Godaddy.
How to buy a domain name in Goddy
With the URL below we can link our website to the type of domain name (www.examplewebsite.com).
This gives us a TXT record and an A record. Add this TXT record to our DNS to validate the domain and add an A record to direct it to our application.
So in this article we created a simple website with React.js and hosted it on Firebase. This can be accessed via the URL indicated below.
I also added a link to buy a domain name from Godaddy and link our website to it.
Here we go:
Like the download…
You might like this.