SPA (single-page application)
A single-page application (SPA) is a web application or website that interacts with the user by dynamically rewriting the current web page with new data from the web server, instead of the default method of a web browser loading entire new pages.
- The frontend app is a static website which served by Nginx or other web server.
- When user visit the website,
index.htmlis served and browser download JS, CSS files.
- The browser will then use the JS to init React / Vue app and build DOM tree.
- And then React / Vue app will interact with API backend through
- We can use create-react-app to create a React application.
- We can use vue-cli to create Vue application.
For Django dev, we might also need below packages.
- Django REST framework which will help build REST API.
- dj-rest-auth or djoser for auth API support.
- django-cors-headers will help solve Cross-Origin Resource Sharing (CORS) issue.
- graphene-django Integrate GraphQL into your Django project.
For Flask dev, we might also need below packages.
Pros and Cons
- Friendly to both frontend and backend developers, and there are many learning resources online about this architecture.
- The decoupled structure is clean, easy to understand.
- Can not benefit from some awesome Django, Flask features (templates, form, built-auth)
- The web application is not SEO friendly and is a little slow on first page load.