# Magma-Web **Repository Path**: mirrors/Magma-Web ## Basic Information - **Project Name**: Magma-Web - **Description**: magma 是构建同构应用的新方法,利用客户端和服务端模板的优势来构建 WEB APP - **Primary Language**: JavaScript - **License**: Not specified - **Default Branch**: master - **Homepage**: https://www.oschina.net/p/magma - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-02-05 - **Last Updated**: 2025-08-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Magma [](https://travis-ci.org/vilmosioo/magma) ### A new way of building web apps by taking advantage of both server and client side templating. ## Working Demo [http://magma-vilmosioo.rhcloud.com/](http://magma-vilmosioo.rhcloud.com/) A web-app that allows you to browse books and authors. ## Context Complex websites have multiple sources to generate the data. A modular architecture allows you to aggregate different components before sending the final document to the user. Let's assume our website's wireframe looks like this. A, B, C, D are separate components built to display various data.  Server-side rendering is the common approach to deliver a document. A user makes a request, the server identifies the resources requested, builds the document and sends it back.  Client-side architecture works in a similar way, except the templating engine is the browser itself. The components are built by JavaScript.  Client vs server templating is an on-going debate today. Magma suggests a hybrid approach, taking the advantages of both and disadvantages of neither. ## How it works Magma is not a framework. You don't need any code from this repository. it does not require you to use a particular tech stack. It is an architecture. It leverages the main content to the server for fast delivery, while everything else is rendered on the client. For example, referencing the wireframe above, your home page contains 4 components: A, B, C, D. On page load, the server will render A and B and send the document to the client. At this point the website is viewable and useful to the user. Once your JavaScript loads, components C and D are loaded using a client rendering engine. After this point the website behaves as a single page application. If you need to render A and B on the client later on, you may call their individual endpoints. // example code from demo  **TLDR** Magma is an architecture that requires the main content to be delivered by the server on page load, and initialising a single page app as soon as JS is loaded. Components should be exposed by individual endpoints. ## Magma AngularJS module ``` npm install magma --save ``` ``` bower install magma --save ``` ### mgView mgView directive allows you to delay route initialisation in your angular application. On `$routechangeSuccess` mgView will replace itself with the standard ngView and the application will behave as a regular SPA. ```