Skip to content
Production ready library for handling Microfrontends
JavaScript HTML
Branch: master
Clone or download
Latest commit 0dbec89 Apr 3, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example/my-awesome-app
src feat(bootstrap): add initial files Apr 1, 2018
.babelrc
.eslintignore feat(bootstrap): add initial files Apr 1, 2018
.eslintrc feat(bootstrap): add initial files Apr 1, 2018
.flowconfig feat(bootstrap): add initial files Apr 1, 2018
.gitignore feat(bootstrap): add initial files Apr 1, 2018
.npmignore chore(example-readme): improve example and README and fix npmignore Apr 1, 2018
.prettierignore feat(bootstrap): add initial files Apr 1, 2018
LICENSE.md
README.md Update README.md Apr 2, 2018
package.json 0.1.3 Apr 2, 2018
rollup.config.js
yarn.lock feat(bootstrap): add initial files Apr 1, 2018

README.md

react-app-loader github

Production ready library for handling Microfrontends.

Demo and Example

Preview

How to use

Create a config file for each external app:

$ touch AnyExternalApp.js

Then, wrap it with withAppLoader HOC:

// @flow

import withAppLoader from '@entria/react-app-loader';

const elementId = 'github';
const appUrl = 'https://github.com/';

const AppLoader = withAppLoader({ elementId, appUrl });

export default AppLoader;

Or you can try a more complex way, passing some props:

// @flow

import React from 'react';
import withAppLoader from '@entria/react-app-loader';

const elementId = 'github';
const appUrl = 'https://github.com/';

type Props = {
  externalUrl: string,
};

const AnyExternalApp = (props: Props) => {
  const { externalUrl } = props;
  const AppLoader = withAppLoader({
    elementId,
    appUrl: externalUrl != null && externalUrl.length > 0 ? externalUrl : appUrl
  });
  return <AppLoader />;
};

export default AnyExternalApp;

Import it on your React app:

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

import AnyExternalApp from './AnyExternalApp';

class App extends Component {
  render() {
    return (
      <div className="App">
        <AnyExternalApp />
      </div>
    );
  }
}

export default App;

Import babel-polyfill on your index.js

import 'babel-polyfill';

Run \o/

Handling cors during development

On Google Chrome, just install this extension: https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi

License

MIT

You can’t perform that action at this time.