cms-react-boilerplate
cms-react-boilerplate copied to clipboard
cms-react-boilerplate [beta]
Boilerplate React project for creating apps using modules on the HubSpot CMS.
NOTE:
The cms-react-boilerplate legacy repository is a starting place for building and running a SPA (single page application) style React App on a HubSpot page. The React build itself is not directly connected to HubSpot.
Recently HubSpot has released "CMS JS Building Blocks" for general availability. Read documentation and view examples here. The "building blocks" feature directly integrates React on the server and the client with HubSpot and enables building HubSpot modules in React. Further, it builds on the HubSpot Developer Projects system which provides CI/CD build and deploy functionality.
Getting Started
For more information on local development tools, see Local Development Tooling: Getting Started
Configuration
Set up HubSpot CMS CLI (@hubspot/cli)
- A config file named
hubspot.config.ymlwill also be needed. The config can be at the project level or higher up in the directory tree. - Be sure to set a
defaultPortalin yourhubspot.config.ymlto which you'd like the built app files to sync.
Install
- Run
npm installoryarn installto install needed dependencies.
Running
- Run
npm startoryarn startto automatically upload your project todefaultPortal. - Create a page from default theme, or any drag-and-drop (
dnd_area) enabled template in your portal, and add theapp (label: React app boilerplate)module.
package.json scripts
start: Builds project with webpack, uploads to yourdefaultPortalspecified inhubspot.config.ymland watches for changes via@hubspot/webpack-cms-plugins/HubSpotAutoUploadPlugin.build: Clears/distcontents and builds project into/dist.deploy: Clears/distcontents, builds project into/dist, and uploads to via@hubspot/cli.lint: Lints CSS, JS, and JSON files viaeslint(documentation) and checks for formatting viaprettier(documentation) insrc.- For configs, see
prettier.config.jsandeslintrc.js.
- For configs, see
prettier:write: Formats JS and JSON files insrc.- For configs, see
prettier.config.js.
- For configs, see