React website structure on firebase hosting - reactjs

Im not sure im in the right place, but ill still ask.
I have a single page app writen in React and an html landing page writen is pure html and css. The two have different css and nothing in one depends on the other. My question is how can I structure the website files in a way that the landing page loading times are very fast and the react app is also acessible? I want to user Firebase Hosting for it.

Related

Is there any particular way to quickly convert a Create-React-App project to a NextJs project?

Overview
I need to improve the SEO / meta data for a React website that I made with the npm pages Create-React-App and React-Router. I would like to remake the website using NextJs in the most efficient and effective way possible. The project is hosted on Netlify.
Background
I am doing this because this is a single page application that uses react-router, and so webpage meta data is not displayed for each page when being shared on social media sites and not rendering in search engine results pages, other than the meta data included with the root index.html page.
assumptions
NextJs includes server-side rendering and static rendering. It's my understanding that this will allow distinct page metadata to be included with each when they appear in search results or in rendered page preview that is generated when the link is shared on various social media sites.
Conclusion
I will completely understand if there is no streamlined way to do this, but I am new to NextJs, and I want to make sure I am not overlooking any methods that would simplify and speed up this task. The client who ordered this site expected meta data to render with each page so they are eager to have to have the SEO improved as soon as possible.

How would I make a large website with React, if React makes SPAs

I want to use react js to make a news website with hundreds of articles. As I understand it, react makes single-page-applications. Surely it is not feasibly to include hundreds of articles in a single-page-application, so how could this be done?
You can absolutely use react to make a single page application which shows hundreds of articles.
The term single-page application describes how the articles are loaded when the user moves between the articles. In a multi-page application, every article will be its own html file. When the user clicks to go to a new article, your server sends a brand new html file, and the browser throws out the old page and shows a new one. In a single-page application, there's just one html file which is loaded at the start. As the user navigates between articles you use javascript to fetch data about that article (but not a full html file), and then you use that data to modify the existing page to look like a new page.

Why is React Js called as Single Page Application

Hello guys i am new to React Js i often hear and see posts regarding react is single page app but never understood what is SPA and many say that it doesn't reload the pages but i didn't understood why so could you guys please explain me with simple examples.
A Single Page Application is a web application or website that interacts with the web browser by dynamically rewriting the current web page with new data from the web server, instead of the default method of the browser loading entire new pages.
This means that the URL of your website will not change completely (page will not reload), instead it will keep getting content and rewriting the DOM with it instead of loading a new page.
The goal is faster transitions that make the website feel more like a native app
Example: Netflix
This is the dashboard, and when we click on any movie, it changes to /watch and the content is rewritten.
In Technical Terms:
When building your react-app, you can see that there is only one
App.js from where your entire web-app is loaded in fragments and
components. This behaviour of rendering components and pages on a single page and changing the DOM( is a single page behaviour and hence the name), instead of loading a new page with new content, this makes it feel like a single application.
As mentioned in Glossary of React Terms:
A single-page application is an application that loads a single HTML page and all the necessary assets (such as JavaScript and CSS) required for the application to run. Any interactions with the page or subsequent pages do not require a round trip to the server which means the page is not reloaded.
And about "Why is React Js called as Single Page Application":
Though you may build a single-page application in React, it is not a requirement. React can also be used for enhancing small parts of existing websites with additional interactivity. Code written in React can coexist peacefully with markup rendered on the server by something like PHP, or with other client-side libraries. In fact, this is exactly how React is being used at Facebook.
A single page application has one single page e.g. www.google.ch. It is exactly one HTML file (with all its required dependencies) loaded into the browser. You'd navigate between paragraphs only using hash-router, but never ever visit another page like www.google.ch/maps (that would then be www.google.ch/#maps, which references / -> index.html) (tho google may not be the best example, it is more about URIs).
ReactJS is an open source JS library for building UI and used for SPA, and it manages the views of web apps. Reactjs can help you to modify your data without reloading of a page. It is a popular library in the market trend because of its scalability & fast performance.
Single Page applications are different from multiple page apps that we see everywhere because the SPA doesn't move into new pages; instead, it will load the pages inline within the same page.
In traditional websites, when we go from one page to another, the whole site is loaded. e.g - if you go from "www.example.com/hi" to "www.example.com/hello" the whole website is reloaded. No matter how much portion of the website is really changed. Let's say, the website has "Sidebar, logo, menu" on both of its pages, then the full reload doesn't make any sense. This takes too much time and decreases the performance.
Single Page Applications, as the name suggests, have only one single page that is loaded the first time you open the website. After this, no matter where you click, it is not gonna refresh the website fully.
browser reload button
The loading icon of the browser doesn't load when we move from one page to another on SPA site, as it does on the traditional websites.
Cons- SPA sites are great for UI UX but they are not the best when it comes to Search Engine Optimisation, it creates problems with rankings.

How to serve static page + react app on same URL like Twitter or FB?

Is it possible to render a static web page if not signed in, but load the SPA (ReactJS) somehow if signed in before? Or are those 'static' web page just part of the app?
What I mean is like Twitter.com or Facebook.com and how they either load the app immediately if you have signed in before, or a default page that is crawl-able.
Is server-side rendering the only answer? Or is there a simpler solution, since most search engine can crawl JavaScript site? I do not want to use a subdomain like app.domain.com if possible.
Idea: most ReactJS tutorials start out with a rather empty index.html with a div that React should renders into. How about a bootstrap html that has actual content and if React detects the user has already logged in then remove those static content dynamically? Is this commonly done? what's the drawback?
This can be solve by using if else condition in react js.
Hope you get user information from an api.
if api give you some user information then you can store that information in state and display them.
and if that state is null then you can display your static page.
By this you can render static page and react js on same page.
Hope this ans will solve your problem

Huge app with webpack

I am planing to develop a huge app (Let's say more than 100 pages with a lot of JS charts and maps) using React, React-Router and Webpack. I believe the size of final JS file is going to be so large and that is going to be so annoying for User during first page load.
Is there any way to load the final JS partially, for example based on the selected route? or I should stick to server-side rendering and using some other libraries like PJAX? I appreciate any other solution as well.

Resources