Reactium
  • Quick Start
  • Discuss
  • Approach
    • Architecture
    • DDD Introduction
    • Domain Model
  • Reactium App Foundation
    • Reactium Guides
      • Creating a Simple Single Page Web App (SPA)
      • Creating a Sassy Style Sheet
      • Reactium Core
      • Reactium + Actinium (APIs)
      • Reactium + REST
      • Plugin Module Guide
      • Animating React Routes
      • Reactium in Production
    • Reactium Domain Model
      • Basic Domain Model
      • Runtime Domain Model
      • Buildtime Domain Model
    • Reactium SDK
      • Reactium SDK Reference
    • Updating Reactium
  • Installing Foundations
    • Before You Install
    • Install Reactium
    • Install Actinium
  • Reactium API Foundation (Actinium)
    • Actinium Core
    • Setting up your User
    • Actinium SDK
      • Actinium SDK Reference
    • Actinium Domain Model
    • Extending
    • Updating
    • Live Query
  • Reactium Toolkit
    • Overview
    • Installation
    • Configuration
    • Customization
    • Creating Elements
      • Sidebar Elements
      • Toolbar Elements
      • Documentation Elements
    • Components
      • Sidebar
      • MenuLink
      • Element
      • Code
      • Markdown
      • Icon
    • Toolkit SDK
Powered by GitBook
On this page
  • Running the Full-Stack Locally
  • Using Actinium in Express Middleware
  1. Reactium App Foundation
  2. Reactium Guides

Reactium + Actinium (APIs)

Reactium foundational web app framework comes with built-in support for the complementary API framework, Actinium, giving you rapid access to built-in cloud functions, and your own API extensions.

PreviousReactium CoreNextReactium + REST

Last updated 2 years ago

The default API experience with Reactium is facilitated by a , Actinium, coupled with a front-end module that makes integration with the API server easy.

The Actinium API module is installed by default. To install it manually, use Reactium CLI:

npx reactium install @atomic-reactor/reactium-api

Out of the box Reactium is ready to work with Actinium with a little configuration. Simply set the REST_API_URL and the ACTINIUM_APP_ID environment variables.

$ export REST_API_URL=https://my.actinium.url/api
$ export ACTINIUM_APP_ID=Actinium
$ npm start

In your Reactium code use the default helper module provided to immediately begin using the Actinium SDK.

/SomeDomain/services.js
import Reactium from 'reactium-core/sdk'; 

export default {
    myCloudFunction: params => Reactium.Cloud.run('myCloudFunction', params)
    .then(data => { /* do something */ })
};

Start Actinium then start Reactium and you're good to go!

While the extensible Reactium SDK is our opinion for the best way to quickly add backend API functionality to your webapp, supporting other client-side APIs is a snap. See .

Running the Full-Stack Locally

Start by installing both and locally.

Once you have Reactium and Actinium installed, you can run the UI server and the API server on the same machine.

For local development, Actinium runs on localhost on port 9000 and Reactium will run on localhost on port 3000 for browser-sync (and 3030 for the base Node/Express server).

Using Actinium in Express Middleware

reactium-boot.js
const bodyParser = require('body-parser');
const express = require('express');
const router = express.Router();

router.use(bodyParser.json());
router.use(bodyParser.urlencoded({ extended: false }));

router.post('/auth', async (req, res) => {
    const { username, password } = req.body;
    const result = await Actinium.Cloud.run('my-auth-function', { username, password });
    res.json(result);
});

ReactiumBoot.Server.Middleware.register('auth', {
    name: 'auth',
    use: router,
    order: ReactiumBoot.Enums.priority.highest,
});

See the to get a visual sense of the relationship between these two servers. In summary, Reactium is a micro-service for serving the front-end of your web-app, and Actinium is a micro-service for building an API (and database) for your application.

There may be a time when you will want access to Actinium when creating Express middleware inside of a file. If you have the reactium-api module installed, Actinium is available out of the box as a global.

separate API server
Reactium + REST
Reactium
Actinium
Architechure Diagram
reactium-boot.js