Creating a Simple Single Page Web App (SPA)
The Reactium foundational framework can be used to build a stand-alone simple Web App. Need a quick React app with routed components, here's how you do it!
TL;DR - from the command line, run:
mkdir myapp
cd myapp
npx reactium init
[ARCLI] > Initialize what type of project?: (Use arrow keys)
❯ Reactium (Web Application)
Actinium (Web API)
# Delete the default component
rm -rf src/app/components/Welcome
# Create Your Home Page!
npx reactium component
[ARCLI] > Select directory: src/app/components
❯ src/app/components
src/app/components/common-ui
[ARCLI] > Component Name: Home
[ARCLI] > Route: /
[ARCLI] > Reactium Hooks?: Yes
[ARCLI] > Domain file?: Yes
[ARCLI] > Stylesheet?: Yes
[ARCLI] > Select stylesheet type:
base
atoms
molecules
❯ organisms
overrides
default
mixins
[ARCLI] > Preflight checklist:
{
"destination": "src/app/components/Home",
"name": "Home",
"route": "['/']",
"hooks": true,
"domain": true,
"style": true,
"styleType": "_reactium-style-organisms.scss",
"className": "home",
"index": true
}
[ARCLI] > Proceed?: (y/N) y
npm run local That's it. You should be looking at a running simple app, with your Home component running on http://localhost:3000
Creating A Page
Let's break down what's happening with the previous reactium command. After proceeding, your scr/app directory should look something like this:
Create a Second Page
Single Page Application Navigation
You already have a React single-page application started.
Let's create a navigation component and render it on both pages!
Ok, let's modify our Nav component:
Let's also add some sassy styles for Nav:
Great, now let's include the Nav in both the Home page and the About page:


Great, Now we are SPA Routing!
But wait, does that mean I have to have common elements like the Nav on every routed page?
Let's create an AppParent component to be the "window dressing" for our app!
Let's move the Nav to the AppParent component, and add some common page structure to the app.
Note that the Footer component need not actually already exist. If someone creates one with that name, it will just show up!
By creating an AppParent component that returns props.children, it will automatically take the place of the component in reactium-core. Registered components are overridden! A good thing!
Final Simple SPA

Last updated