Developer forum

Forum » Development » Headless DW Routing

Headless DW Routing

Natan Ólafsson
Natan Ólafsson
Reply

Hello

We have been looking into how we can take advantage of the WebApi introduced in 9.10 and possibly transition into a SPA frontend.
Have you found any solution on how to handle routing in the react/vue app, so that pages & paragraphs can be created/edited/deleted without needing to update the SPA app. We want to avoid having to hard-code the routing in react/vue, possibly by using Dynamic Components, but we can't figure out a good way to handle routing.

We are also concernced with how to use the visual editor with a SPA frontend, any thoughts on how to make that work?

Regards
Natan Örn Ólafsson


Replies

 
Nicolai Pedersen
Reply

Hi Natan

Creating a frontend in react/vue/etc. kind of takes over the head of our application and we do not provide a specific solution for that - i.e. routing, state of users etc. One solutioin is to use polling - you have a navigation endpoint in the webapi that will return the logic of the navigation including URLs and IDs (use the version with expandmode=all) and you can probably map that directly as is in your implementation and detect changes. That endpoint should be what you need in order to map URLs to pages. If you need anything in this regard, you can also let us know and we will look at a solution. Could be GetPageByUrl or something like that.

An alternative is to create your own websocket endpoint that will hook into our notifications using notification subscribers and report back to your SPA with changes - either the changes or just that something changed. Alternatively a SignalR endpoint.

In terms of visual editor - using a 'headless' frontend - it is kind of 2 scenarios in 2 completely different directions. The only solution to that problem as I see it, is to create 2 frontends. One for Visual Editor and one for your SPA. Dynamicweb injects the information it needs and builds the grid on the server and I cannot think of a way to hook into that from your SPA and support Visual Editor in that way.

 

You must be logged in to post in the forum