create-app

raw JSON →
2.1.0 verified Fri May 01 auth: no javascript

A JavaScript library for isomorphic (client/server) single-page applications with unified configuration for routing and rendering. Version 2.1.0 is the latest stable release. Key differentiators include a single configuration for both client and server rendering, built-in history management, and minimal boilerplate. Designed for use with ES6 transpilers like Babel, with separate entry points for client and server.

error Module not found: Can't resolve 'create-app'
cause Installation missing or incorrect import path.
fix
Run 'npm install create-app' and use correct import path: 'create-app/client'.
error TypeError: createApp is not a function
cause Default import without subpath returns undefined.
fix
Import from subpath: 'import createApp from "create-app/client"'.
error Cannot read property 'push' of undefined
cause App not started or history not initialized.
fix
Call 'app.start()' before using 'app.history.push()'.
gotcha Rendering fails if container element does not exist in DOM on client side.
fix Ensure the container element (e.g., 'body') exists before calling createApp.
deprecated The 'start' method second argument (resolve) is deprecated in v2.0.0.
fix Omit the second argument or use 'app.start()' without resolve.
breaking In v2.0.0, the API changed from using 'createApp()' without arguments to requiring a configuration object.
fix Pass a configuration object like { container: 'body', basename: '/' }.
gotcha CommonJS require without subpath does not export anything.
fix Use 'require("create-app/client")' or 'require("create-app/server")'.
npm install create-app
yarn add create-app
pnpm add create-app

Demonstrates creating a client app with a container and basename, starting it, and pushing a random history entry.

import createApp from 'create-app/client';

const app = createApp({
  container: 'body',
  basename: '/abc',
});

app.start();

let targetPath = `/random${Math.random().toString(36).substr(2, 6)}`;
app.history.push(targetPath);