Skip to main content
Use this approach when you want a ready-to-use browser client that already knows how to:
  • connect to WebSocket/STOMP (/ws with SockJS fallback to /sock)
  • subscribe to the default topics (/topic/msm/* and /user/topic/msm/*)
  • publish SSR render and JSON requests

Setup

Include the bundle and initialize the app:
If you initialize the client from an ES module, you can export the instance:
MSM2.App opens the WebSocket connection automatically and registers default listeners for HTML and JSON responses.

Initialize with msm-framework-js

When the library is loaded as a separate browser script, create the client after it has loaded. Pass the WebSocket endpoint of your application:
Replace wss://music.mastermindcms.com with your application’s WebSocket URL. In a bundler, you can add msm-framework-js as a dependency and use the same new MSM2.App(...) call.

Calling APIs

After initialization, MSM2App exposes convenience methods for the two WebSocket request styles:
  • render (SSR): renderPage, renderElement, invokeAndRender, updateBeanAndRender, addToRepositoryAndRender, saveToRepositoryAndRender, removeFromRepositoryAndRender, addDocumentAndRender, removeDocumentAndRender
  • JSON: invoke, invokeAndGetJson$, updateBeanAndGetJson$, repository calls, and database document calls

Example: SSR render

Example: call a backend service and get JSON

Example: custom topic subscription

If your backend publishes custom events under /topic/**, you can register an additional listener:

Notes

  • For JSON calls, use actionId correlation if you are building your own request messages. When using invokeAndGetJson$ and similar helpers, the client generates actionId automatically.
  • Authorization can be done via session/remember-me cookies or via JWT, depending on your configuration.