Modern web browser
Use a modern browser with support for ES modules, Custom Elements, Shadow DOM, and standard browser APIs.
Start a ModularCube application from an empty directory and get a working project running locally in a few steps.
This guide walks through the complete initial setup: preparing the environment, creating the project files, configuring the application, starting a local server, and creating your first component.
Before creating the project, make sure your development environment can serve ES modules over HTTP.
Use a modern browser with support for ES modules, Custom Elements, Shadow DOM, and standard browser APIs.
Use any editor capable of working with HTML, CSS, JavaScript, and JSON files.
The application must be served through HTTP so that JavaScript modules can be loaded by the browser.
Create a directory for your application and open it in your preferred code editor.
Create a new directory for your ModularCube application.
mkdir my-project
Move into the directory you just created.
cd my-project
Create the three files that form the initial application:
These files provide the document entry point, application initialization, and component configuration.
The application can begin with a few files at the project root and grow as components, services, modules, and assets are added.
Components can be grouped under
src/components/, while additional directories can
be introduced for services, reusable modules, and static assets.
Open
app.config.json
and define the application root and the components that will be
available to the application.
The
application
section defines
app-body
as the root component of the application.
Application root
The application configuration defines the application
root through its name property. However, when the same
component is registered in the components list,
the registered component takes priority and the
application definition is not used to register it.
The
index.html
file is the browser entry point. Add the ModularCube import map
and load the initialization script.
The application root can receive its content in two ways. Choose the approach that best matches how the application is structured.
Document-oriented
Place the application content directly inside <app-body> using a <template>.
This approach keeps the page's content structure directly in the HTML document. The content is therefore part of the document source and can be understood by browsers, search engines, accessibility tools, and other systems that inspect the page document.
This is generally the preferred approach for content-oriented websites where the document structure and its content are important.
Component-oriented
Keep the application root in index.html and define its content in a separate HTML file.
When the content is stored separately, the HTML file must be declared in the application's files.html.path configuration.
This approach keeps the document entry point minimal and moves the application's markup into the component's own HTML resource. It can be useful for application-style interfaces where the application content is treated as part of the component rather than as the primary document content.
Open
init.js
and initialize the framework using
Dom.init().
When no configuration path is supplied,
Dom.init()
looks for
app.config.json
next to
init.js.
Start a local HTTP server from the project directory. For example, if Python is available on your system:
Start a local HTTP server from your project directory.
python3 -m http.server 8000
Open the local application in your web browser.
http://localhost:8000
Do not open index.html directly from the file
system. The application should be served through HTTP so that
browser module loading works correctly.
Content or functionality unavailable
Some content and features in this application are still under development and are not yet implemented. They will become available in a future release. Thank you for your patience and understanding.