I really love working with Craft, especially around how easy and user friendly it is. However, I do work with React/Vue and usually I setup a node server/app that will do some routing, render views and so on...

Would it be a good idea to have a setup like this:

  • Frontend: React / Vue
  • Backend: node app that has all my public routes setup, rendering views, server side render React/Vue etc
  • Backend no 2: Craft CMS with Element API setup

Example:

  • User requests /contact/person-1
  • The request will be matched in my node app as a valid route
  • Node app will make request to the API that has been setup for Craft, fetches the relevant info about Person 1, returns the result to node
  • Node app renders the view with the data that was fetched

Is this O.K. or completely nuts? Will it be ineffective or is it a good way to structure it like this when I'm in need for a nice CMS like Craft... ?

Please help me out on finding the best approach!

up vote 1 down vote accepted

So you can definitely do this... the article Using VueJS + GraphQL to make Practical Magic has a detailed explanation of how to accomplish this using the CraftQL plugin and GraphQL... which I think you may find much nicer to work with than custom Element API endpoint(s).

However you can definitely do it with an Element API endpoint as well. It's just a bit more work, and a bit more in PHP-land.

  • Cool, thanks. Will give it a try! – nickelman Oct 10 at 19:08

Sounds like you're using craft in 'headless' mode. I've heard about that for drupal, but not for craft. I don't see any reason why it wouldn't work. You get the craft UX for creating and modifying entities, but use node as a proxy and view generator.

  • Yes, exactly, looks like it could be a nice way to go then. Cheers – nickelman Oct 10 at 19:09

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.