Reputation: 223
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.
Upvotes: 1
Views: 4402
Reputation: 5393
Yes. SPA apps do need to live somewhere (as you need to host the assets (js, css, initial html, other)
You need to setup somewhere to host the entry files as per the short answer. In the past I've used anything from:
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.
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.
Upvotes: 0
Reputation: 180
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.
Upvotes: 4
Reputation: 161
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
Upvotes: 0
Reputation: 55623
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.
Upvotes: 4