Hosting React/Redux Web Apps (front end) - reactjs

One thing I do not quite understand yet is this. Say I have a website or single page app, made with React/Redux. Say I have no API calls or anything like this, so it's just the front-end I am talking about.
Do I have any restrictions when it comes to hosting?
People speak of Heroku & AWS here a lot, but as I understand it this concerns only the backend (?) Could I just host my React site with a 'traditional' provider or would I have to look out for something more specific?

There are no specific requirements for hosting a react JS webapp.
Let's say you're using webpack to build your webapp, it'll build a static javascript file that need to be served just like regular static assets.
So just the way you'd serve any other website that has static html/css/js assets.
That is the case when you've no special requirements. Now if you wish to build on the server you'd expect the server to run nodejs and have decent memory to support the build process. If you need to do caching/load balancing/rate limiting you'll have to use different required solutions.

Related

Is Single Page Application needs a Application Server?

I'm new to SPA development, so this may be a stupid question. please understand.
My question is "Is SPA(Single Page Application) needs a Application Server?"
As I understand it, the SPA gets the response after calling REST API. It use that response to re-render.
If so, is the server that handles REST API "Application Server"?
So many posts say Application Server are tomcat, oracle, etc... and they are also say Application Server handle the request to access the database. Then what is "Application Server" in SPA? or there are no Application Server in SPA?
(Are there any architectures or systems I'm not aware of?)
If I'm misunderstanding the architecture, please let me know.
I want to understand web server and Application Server in SPA. So I have read many posts but I'm still confused.
Thanks.
A SPA needs one server to serve the SPA bundle to the users browser.
If the SPA interacts with an API or APIs, the API(s) could be hosted on the same server that served the SPA bundle, or they could be hosted on other servers.
A Single Page App requires a server to serve the .css, index.html, and .js files it requires. It is not a requirement that that an SPA must communicate with an application server via any means at all.
Your content can be static or self generated by the app itself. Should you require communication with a backend server, you can consume that via some sort of api over
protocols such as http, https, websockets or Server Side Events.
To summarize. An SPA can be completely self contained OR access an api to provide functionality. A standalone app requires a server only to serve the component files (.css, .js, .html) of the app itself.
With SPA as well you will have html file and images, js, css files that will be loaded when you launch your single html webpage. So you need to host this static content on some server. So it can be separate web server or same APIs
server(Application Server) which can host these static content and serve request for those files. It can be also hosted on cloud static server and distributed via CDN
Short answer:
Yes. SPA apps do need to live somewhere (as you need to host the assets (js, css, initial html, other)
Long Answer:
You need to setup somewhere to host the entry files as per the short answer. In the past I've used anything from:
NodeJS code base services running on a Docker container (app & assets being served via express), to
dotnetcore on a similar stack (With kestrel server serving the assets running on docker on ec2).
Docker container running Apache webserver hosting the statically compiled assets
More recently I've dabbled with compiling the SPA app to a bunch of static assets (such as the ability NextJS / Gatsby provides with their tooling, but there are tons of others or alternatives in other SPA worlds)... but even then you'll need to host those assets somewhere.
S3 on Amazon has the ability to host SPA apps directly via a bucket setting & providing an entry point
Vercel (...or any other SaaS alternatives, Vercel is just where I host my personal stuff and has been easy to get going)
Again it's all up to you, but yes, you still need to make the JavaScript available somehow, you just need to pick your mechanic. SaaS with a baked in WebServer such as Vercel, a CDN like S3 that AWS provides, or go totally custom and spin up your own WebServer as application entry.

Simple static website can interact with database?

Let's say that I would like to build a very simple website which retrives the content from a database but instead of building a dynamic site, which should be deployed in a VPS or a PaaS I want it to be static so it can easily run in any kind of web hosting.
Is that possible? Maybe using a CDN library like axios or jquery?
Thanks!
Since static Web pages contain fixed code, the content of each page does not change unless it is manually updated by the webmaster. So what you asked for is not a static website.
You need to use at least one server-side programming language (like PHP) to make a connection to a database.
And about compatibility, you don't need to look around VPS or PaaS at the start point, depended on your PL (programming language) and database you can choose your web hosting service from shared hosting providers, as your website growing and you learn more about the web stacks you can think about the dedicated host on VPS or use cloud service and ...

Deploy non-web Java application

I have a relatively small Java app, which I'd like to move over to the Google App Engine. It runs in the console, with no user input needed after the initial startup. I researched a bit on how to deploy it, but all tutorials seem to focus on Java web apps, when I don't really need that. Is it possible to deploy my app if it's not a web app?
App Engine is probably the wrong GCP platform for you - you'd probably be better served just deploying your jar directly onto a Google Compute Engine node. GAE is pretty explicitly oriented around web applications and you'd need to do a bunch of configuration in order to have it work for your use case.
Does your non-web Java app handle web requests? If not, it seems difficult to imagine that you would be able to reach your deployed app and use it for any purpose, once deployed. Your Java app should be able to handle requests, to make deployment worthwhile, and the deployed app useful.
You may find out about how your app should handle requests by reading the How Requests are Handled documentation page.

Do I need Nginx alongside nodejs in production (using Firebase for hosting and database)

I have the below configuration
Firebase - for hosting (serving static files) and storing data
(Database).
Nodejs - for making API calls to Firebase, Twilio and Sendgrid.
Angularjs - for frontend
Do I need Nginx for the above configuration ? looking at answers like these makes me consider Nginx.
My app is intended to serve several hundred users.
No, you do not NEED nginx. There are zillions of node.js apps at the scale you describe that do not need to use something like nginx.
You would use Nginx if you had a specific problem in your deployment and Nginx was the easiest/best way to solve that problem. You have not described any specific problem (other than scaling to a few hundred users which node.js can do just fine by itself) so you have not described any reason that you need Nginx.
Nginx has a bunch of things it is great at, but until you identify a specific need for more than node.js offers, I would not recommend that you complicate your deployment just because Nginx helps some people. Instead, deploy your app, measure its performance, understand where your weaknesses are and then evaluate if Nginx is the best tool to help you fix any weaknesses that need fixing.

Can I use Ionic without node.js to build a hosted web app?

I am interested in using Ionic to build a web app. The tabs, form stuff, integration with angular.js... everything looks like it should work great.
However, Ionic also looks to be geared towards creating native apps for Android and IOS. It relies on node.js for services. I'll just be hosting it on my client's shared hosting account - I won't be able to get node.js working for it. I don't intend to develop the app to use any services, so I don't think I need node.js. I'll plan to communicate with my DB via http post.
I am interested to know - is there any reason I wouldn't do this? If I am not using any other means of communicating with a server, will I be okay without node.js? Is there a better option for creating an html5 mobile 1 page web app?
I also don't intend to access the camera, accelerometer, or any of that kind of thing, so I don't think I'll need cordova, either.
ionic uses node.js only for development, things like build, test and deploy
not necessarily for back-end proposes

Resources