ui5-cap-serverside-rendering-plugin
A CAP plugin that fills UI5 views and fragments with entity data on the server through Handlebars and streams them as XML, and renders a Vue app to HTML on a route of its own.
A UI5 view reaches the browser as a template and fills itself once the framework has booted and read its data. This plugin does the filling on the CAP server: a view or fragment lives under srv/views or srv/fragments with its UI5 bindings rewritten as Handlebars expressions, and the entity extends the plugin's ServerSideRendering aspect, which adds the virtual content, mediaType and fileName elements the result is served through. An after READ handler answers a request for that entity's content, compiles the template against the rows read and streams it back as application/xml. Which file it reads follows from @ServerSideRenderingType and @ServerSideRenderingName, or, failing those, from the entity name plus List or Detail, and a read with keys expands the entity's associations and compositions so a detail fragment carries the record and what hangs off it. A second path serves Vue rather than UI5: an entity annotated @VueApp registers a /vue-ssr route that calls Vue's renderToString and substitutes the markup and the captured state into an HTML template at {{APP_HTML}} and {{APP_STATE}}.
Facts
Where it sits
Who is behind it
In the atlas: maintains 25, contributes to 39, wrote 12@lemaiwomaintainerVolker BuzekContributes to this
In the atlas: maintains 7, contributes to 53, wrote 2@vobu1 contributor
Before choosing this
Conditions
LicenceSAP Developer License Agreement 3.2 CAP§ 1, 2, 3A cds-plugin is used with SAP CAP materials, or an artifact is explicitly identified as a CAP plugin or application.
- § 1 License. Productive customer applications are limited to SAP BTP or another SAP-licensed platform, and mass extraction to a non-SAP product is restricted except where solely required for SAP interoperability.
- § 2 Intellectual Property. The agreement retains SAP's rights in the covered materials and limits making APIs, tools or software available to third parties, while preserving ownership of customer applications subject to SAP's underlying rights.
- § 3 Artificial Intelligence Training. The agreement prohibits use of the covered materials and customer applications for training artificial-intelligence models or systems.
PracticalFunctional boundary
On the UI5 path what comes back is an XML view or fragment with the data already substituted, streamed as the entity's media content, rather than an HTML page — the README calls this pre-rendering, and only the Vue path produces markup. The view kept under srv/ has its UI5 bindings replaced by Handlebars expressions, so it is a second copy of the view, separate from the one the application ships. Version 1.0.8 declares @sap/cds >=8 as its peer dependency, which puts a project on CAP 7 outside its stated range.
What it declares
Every artifact
- Type
- CDS plugin
- Origin
- Independently maintained
- Runtime
- Node.js
As a CDS plugin
- Declared for
- >=8
- Distributed through
- npm
Connections
Rendering a UI on the server before it reaches the browser
Demo CAP bookshop with server-rendered UI5 views
Download
Install
npm add ui5-cap-serverside-rendering-pluginDerived from the package name. No recipe recorded; the README has the configuration.
Learn more
- Create your first CAP pluginCreate your first CAP pluginA step-by-step guide to the cds-plugin.js extension point: scaffold a package, add an index.cds for shared model artifacts, and test it locally against a throwaway CAP project before publishing to npm, with a separate section on building the same plugin in TypeScript and compiling it with tsc. Points to the author's own cds-plugin-handlers and ui5-cap-serverside-rendering-plugin as worked examples.published 2024-12-09Wouter Lemaire, SAP Community
README
quoted from lemaiwo/ui5-cap-serverside-rendering-plugin under Apache-2.0, readui5-cap-serverside-rendering-plugin
CAP CDS Plugin that enables UI5 pre-rendering on a CAP server. Views or fragments can be developed/stored in the CAP service using handlebars for bindings. This plugin will enable the defined entities to get the data from an entity and replace the handlebar bindings in the view with the data and return a pre-rendered view or fragment.
Installation
npm install ui5-cap-serverside-rendering-plugin
Usage
Create a folder "views" or "fragments" in the "srv" folder of your CAP project. Move your UI5 view or fragment into this folder and replace the UI5 bindings with handlebars, e.g.: https://github.com/lemaiwo/ui5-cap-serverside-rendering-plugin/blob/main/tests/demo-project/srv/views/BooksList.view.xml
<List headerText="Books" selectionChange="onSelectedBook" mode="SingleSelectMaster" >
{{#each Books}}
<StandardListItem
type="Active"
title="{{title}} - {{ID}}"
description="{{author}}">
<customData>
<core:CustomData key="ID" value="{{ID}}" writeToDom="true" />
</customData>
</StandardListItem>
{{/each}}
</List>
Enable an entity for this pre-rendering by loading the plugin and add the aspect "ServerSideRendering" to the entity. Next to that, you can also define if you like to use views or fragments. The plugin will use view as the default in case this is not defined: https://github.com/lemaiwo/ui5-cap-serverside-rendering-plugin/blob/main/tests/demo-project/db/schema.cds
using { ServerSideRendering } from 'ui5-cap-serverside-rendering-plugin';
entity Books@(ServerSideRenderingType:'view'):ServerSideRendering {
key ID : Integer;
title : String;
stock : Integer;
}
Example
You can find a demo project here: https://github.com/lemaiwo/ui5-cap-serverside-rendering-demo
History
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
Contributors
History in the atlas
- CAP plugin that fills UI5 views and fragments with entity data on the server through Handlebars, and renders a Vue app to HTML on a route of its own.
- written from the README, index.cds and cds-plugin.js on main, read 2026-09-22
- the XML-not-HTML boundary, the duplicated view, and the stated CAP 8 floor
- the Vue path's REVISIT markers and its one-app-per-server configuration
- the same edge in object form, with what_it_does and two sources
- First seen.
For your agent
- Ref
artifact:lemaiwo-ui5-cap-serverside-rendering-plugin- JSON
- /artifacts/lemaiwo-ui5-cap-serverside-rendering-plugin.json
- MCP
- Connecting an agent