All Projects → magnolia-cms → react-demos

magnolia-cms / react-demos

Licence: MIT license
Demonstrates how to content manage React apps with Magnolia CMS

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-demos

Sanity
The Sanity Studio – Collaborate in real-time on structured content
Stars: ✭ 3,007 (+14935%)
Mutual labels:  headless
Taiko
A node.js library for testing modern web applications
Stars: ✭ 2,964 (+14720%)
Mutual labels:  headless
CrawlerSamples
This is a Puppeteer+AngleSharp crawler console app samples, used C# 7.1 coding and dotnet core build.
Stars: ✭ 36 (+80%)
Mutual labels:  headless
Pdf Bot
🤖 A Node queue API for generating PDFs using headless Chrome. Comes with a CLI, S3 storage and webhooks for notifying subscribers about generated PDFs
Stars: ✭ 2,551 (+12655%)
Mutual labels:  headless
Hiper
🚀 A statistical analysis tool for performance testing
Stars: ✭ 2,667 (+13235%)
Mutual labels:  headless
chrome-headless-launcher
Run the latest Chrome browser on CLI without head
Stars: ✭ 39 (+95%)
Mutual labels:  headless
Storyblok
You found an issue with one of our products? - submit it here as an issue!
Stars: ✭ 206 (+930%)
Mutual labels:  headless
CockpitCMS-React-Static
Example implementation using a combination of Cockpit Headless CMS and React Static
Stars: ✭ 24 (+20%)
Mutual labels:  headless
Serverless Puppeteer Layers
Serverless Framework + AWS Lambda Layers + Puppeteer = ❤️
Stars: ✭ 247 (+1135%)
Mutual labels:  headless
FlexDotnetCMS
A powerful, flexible, decoupled and easy to use and Fully Featured ASP .NET CMS, it can also be used as a Headless CMS
Stars: ✭ 45 (+125%)
Mutual labels:  headless
Ppspider
web spider built by puppeteer, support task-queue and task-scheduling by decorators,support nedb / mongodb, support data visualization; 基于puppeteer的web爬虫框架,提供灵活的任务队列管理调度方案,提供便捷的数据保存方案(nedb/mongodb),提供数据可视化和用户交互的实现方案
Stars: ✭ 237 (+1085%)
Mutual labels:  headless
Core
🧿 Bolt 4 core
Stars: ✭ 243 (+1115%)
Mutual labels:  headless
macaca-puppeteer
Macaca puppeteer driver
Stars: ✭ 39 (+95%)
Mutual labels:  headless
Tensei
🚀 Content management and distribution with a touch of elegance.
Stars: ✭ 217 (+985%)
Mutual labels:  headless
puppeteer-lambda
Module for using Headless-Chrome by Puppeteer on AWS Lambda.
Stars: ✭ 117 (+485%)
Mutual labels:  headless
Xvfbwrapper
Manage headless displays with Xvfb (X virtual framebuffer)
Stars: ✭ 209 (+945%)
Mutual labels:  headless
Sourcebit
Sourcebit helps developers build data-driven JAMstack sites by pulling data from any third-party resource
Stars: ✭ 252 (+1160%)
Mutual labels:  headless
headless-docs
WP Engine Headless Documentation for Developers
Stars: ✭ 34 (+70%)
Mutual labels:  headless
wagtail-headless-preview
Previews for headless Wagtail setups
Stars: ✭ 99 (+395%)
Mutual labels:  headless
capybara-chrome
Chrome driver for Capybara using Chrome's remote debugging protocol
Stars: ✭ 27 (+35%)
Mutual labels:  headless

react-demos

Demonstrates how you can Content manage your React app.

Using three techniques:

  • Magnolia Components: Magnolia components can encapsulate React Apps, allowing content authors to configure them and add them to pages.
  • Magnolia Page: A SPA (single page app) React app can be supplied in a Magnolia page template.
  • Headless: A completely independent SPA accesses Magnolia content in a 'headless'/'decoupled' fashion.

With these key use cases :

  • Content Pool: Content can be managed in a Magnolia content app.
  • Configure: Author can configure the formula used.
  • Labels & i18n: Author can supply labels for apps, and in multiple languages.
  • Marketing: Author can supply 'Marketing promotion content' in the form links, texts and images.
  • Headless: Headless, headless, headless

Features - 1. Magnolia Components

react-calculator

A simple web based calculator that applies an author specified formula to two values.

react-tour-search

A widget which lists content from a REST source and allows filtering via a search input field.

Features - 2. Magnolia Page

A Magnolia page template that delivers a single page app. The tours content is rendered directly in the page via template script so no REST call is required.

Features - 3. Headless / Decoupled

A React app running on another server gets content from Magnolia content apps via REST calls.

Demo setup

To install and run Magnolia, you'll need Java and npm installed. Here's a guide for that: https://documentation.magnolia-cms.com/display/DOCS61/Installing+Magnolia

Should work on Magnolia 5.6.5 and above. Tested most recently on Magnolia 6.1.

  • Install the Magnolia CLI globally with npm install @magnolia/cli -g. This installs the (handy-dandy) mgnl command.

  • Get a Magnolia server by running mgnl jumpstart in the root of this repository. Choose option 3, magnolia-community-demo-webapp, or another option which includes the demo content. (It gives you some demo content, 'tours', a site and theme configuration for resizing images, and a good CORS configuration.)

  • Start the Magnolia server with mgnl start.

  • Log into Magnolia - http://http://localhost:8080 (Author instance)

  • In the Assets app, use the Import action to import the _dev/demos/ dam.react-demo-components.xml file. (You can import it into existing folders, or add a folder.)

  • In the 'AdminCentral' Pages app, use the Import action to import _dev/demos/ website.demo-react.xml file.

Demo - Magnolia Components and Page

In the Pages app, open the various pages under demo-react that have been imported.

(Note that 'decorations' are provided so that the two components are available in the MTK basic page, and the Travel demo pages.)

Demo - Headless scenario.

Follow the above steps first.

Ensure Magnolia is running.

  • Open a terminal in /react-tours-headless directory.

  • Type npm install

  • Type npm run

  • A browser will open a node-based dev server running an independent React App. It get content from the Magnolia Server content apps: Tours and Tour Categories.

Headless Demo Debugging

Does the page display "NOT LOADED"? Then check the browser console for errors, and review the following notes:

Note: To avoid CORS errors (like 'Cross-Origin Request Blocked'), and allow the React app which is running on a node dev server to access the independent Magnolia server, the 'proxy' feature of 'create-react-app' (or webpack?) is used. (All requests for unknown files are proxied to the specified address. The proxy is set in react-tours-headless/package.json). An alternative is to use Magnolia CORS filter module. For More information on the filter see: https://wiki.magnolia-cms.com/display/WIKI/CORS+filter+documentation

Ensure that the base url to access the content on the Magnolia server is correct: In file /react-tours-headless/public/index.html, check that the window.MAGNOLIA_BASE_URL has the correct value for your server. (Probably it does, default is magnoliaAuthor. And that, with the proxy, should go to http://localhost:8080/magnoliaAuthor)

Notes

The react-tours-headless and the 'Page demo' run the same React build.

That app is based on the create-react-app project and can be built with the npm run build command.

The build generated in /react-tours-headless/build directory has been copied to /light-modules/react-demo-page/webresources/build.

The app is built to accept 'parameters' via the JS window global object. In the headless scenario, the app gets the tours content via REST. In the page template, the content is supplied directly in the page so that no additional https requests are required. In the page template, this is accomplished with a javascript model which runs JS on the server to hit the exact same REST endpoints. That js model is here: /light-modules/react-demo-page/templates/js/backend-rest-model.js.

The headless example, and the react-tours-search component, rely Magnolia REST delivery endpoints. Those endpoints are simple to provision. See /light-modules/react-demo-endpoints.

I like developing directly against the Magnolia 'author' instance. App.js passes auth headers for the default superuser account to make this work. For actual project you would typically hit the 'public instance and simply ensure the anonymous user in Magnolia has proper access rights to the REST endpoints.

Project has been updated to newer React and CRA versions, but should be compatible with React 15 too.

Future Improvements

Compiled React apps for components?

The two component examples use uncompiled React apps. In production you will actually want to use compiled React apps. In this case you will need another approach to pass in props from the CMS. I hope to update these examples at some point to use one of the following two techniques:

How to use create-react-app dev server for Magnolia components?

Dev mode is so comfortable since the app is rebuilt on every change. But with webpack dev server, by default, no files are written to disk - so its not possible for the CMS to access your latest react app while you are developing.

TODO: I now know how to do this! Add here.

Information on Magnolia CMS

This directory contains several Magnolia 'light modules'.

https://docs.magnolia-cms.com

Search the docs for sharing light modules for details on how to share and use light modules on npm and github.

License

MIT

Contributors

Magnolia, https://magnolia-cms.com

Christopher Zimmermann, @topherzee

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].