All Projects → abramstyle → kaonjs

abramstyle / kaonjs

Licence: other
Kaon.js is a react isomorphic app solution. It contains webpack build, hot reloading, code splitting and server side rendering.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to kaonjs

Typescript Hapi React Hot Loader Example
Simple TypeScript React Hot Loading example with Hapi Server-side rendering
Stars: ✭ 44 (+109.52%)
Mutual labels:  isomorphic, code-splitting, server-side-rendering
isomorphic-react-redux-saga-ssr
Isomorphic, React, Redux, Saga, Server Side rendering, Hot Module Reloading, Ducks, Code Splitting
Stars: ✭ 19 (-9.52%)
Mutual labels:  isomorphic, code-splitting, server-side-rendering
Koa React Universal
lightweight React-Koa2 universal boilerplate, only what is essential
Stars: ✭ 112 (+433.33%)
Mutual labels:  koa, isomorphic, code-splitting
Hapi React Hot Loader Example
Simple React Hot Loading example with Hapi Server-side rendering
Stars: ✭ 44 (+109.52%)
Mutual labels:  isomorphic, code-splitting, server-side-rendering
Blog Frontend Project
Web frontend code for my blogs, develop with Vue.
Stars: ✭ 206 (+880.95%)
Mutual labels:  koa, server-side-rendering
Koot
Koot是基于React和Koa的WEB全栈技术解决方案。
Stars: ✭ 59 (+180.95%)
Mutual labels:  koa, isomorphic
numvalidate
Phone number validation REST API
Stars: ✭ 54 (+157.14%)
Mutual labels:  koa, server-side-rendering
boldr
React based CMF / blogging engine using Redux, Postgres, Node, and more...
Stars: ✭ 78 (+271.43%)
Mutual labels:  isomorphic, server-side-rendering
Beidou
🌌 Isomorphic framework for server-rendered React apps
Stars: ✭ 2,726 (+12880.95%)
Mutual labels:  isomorphic, server-side-rendering
ves
Vue SSR(Server Side Render) Web Framework for Egg
Stars: ✭ 23 (+9.52%)
Mutual labels:  isomorphic, server-side-rendering
koa-react-redux-universal-boilerplate
[Unmaintained] A fullstack Koa + React + Redux Universal Boilerplate to speed up your development process.
Stars: ✭ 22 (+4.76%)
Mutual labels:  koa, server-side-rendering
redux-react-koa-isomorphic-counter-example
Isomorphic port of the redux counter app
Stars: ✭ 77 (+266.67%)
Mutual labels:  koa, isomorphic
untool
JavaScript tooling platform that focuses on universal React applications. Supports advanced features such as hot-reloading, static and dynamic server side rendering and code splitting.
Stars: ✭ 18 (-14.29%)
Mutual labels:  code-splitting, server-side-rendering
react-ssr-hydration
Example of React Server Side Rendering with Styled Components and Client Side Hydration
Stars: ✭ 15 (-28.57%)
Mutual labels:  isomorphic, server-side-rendering
Rephic
💼 Rephic 是一个基于 Koa 的 React 服务端渲染工程脚手架。支持 React-Router, Redux 以及 Less, Sass。
Stars: ✭ 23 (+9.52%)
Mutual labels:  koa, isomorphic
universal-react-relay-starter-kit
A starter kit for React in combination with Relay including a GraphQL server, server side rendering, code splitting, i18n, SEO.
Stars: ✭ 14 (-33.33%)
Mutual labels:  isomorphic, server-side-rendering
universal-react-starter-kit
Universal React Starter Kit is an universal web application framework using koa, react, redux and webpack.
Stars: ✭ 13 (-38.1%)
Mutual labels:  koa, code-splitting
docker-bare-infra
Docker based, minimal infrastructure boilerplate, with MySQL, WordPress, a React application and Nginx
Stars: ✭ 11 (-47.62%)
Mutual labels:  isomorphic, server-side-rendering
fastify-vite
This plugin lets you load a Vite client application and set it up for Server-Side Rendering (SSR) with Fastify.
Stars: ✭ 497 (+2266.67%)
Mutual labels:  isomorphic, server-side-rendering
Use Ssr
☯️ React hook to determine if you are on the server, browser, or react native
Stars: ✭ 230 (+995.24%)
Mutual labels:  isomorphic, server-side-rendering

kaon.js

Kaon.js is an react isomorphic app solution. it contains webpack build, hot reloading, code splitting and server side rendering.

From

Kaon is a Decepticon-controlled city-state in the southern hemisphere of Cybertron. Under Decepticon rule, its capitol is the fortress of Kolkular.

The pronounce

['keɑn]

The main stack

  • koa
  • react
  • redux
  • react-router
  • react-helmet
  • webpack
  • postcss
  • react-hot-loader
  • loadable-components
  • babel

Usage

install

npm install kaonjs

or with yarn

yarn add kaonjs

add your config

Config is a js file that default exported a Javascript object, it specified a lot ot configurations. The default path is <project_root>/config/kaon.config.js. But you can put it into anywhere of your project.

The config file is not required, Kaon will use the default config as below:

const kaonConfig = {
    ssr: true,
    onlyServer: false,
    renderer: {
      template: path.resolve(__dirname, '../isomorphic/template'),
    },
    app: {
      name: 'Kaon Config Template (production)',
      shortName: 'rib',
      port: 1827,
      routes: `${baseDir}/app/routes`,
      middlewares: `${baseDir}/app/middlewares`,
    },
    resources: {
      root: `${baseDir}/public`,
    },
    isomorphic: {
      routes: `${baseDir}/src/routes`,
      store: `${baseDir}/src/store/configureStore.js`,
      main: `${baseDir}/src/client`,
    },
    postcss: {
      path: `${baseDir}/config/postcss.config.js`,
    },
    webpack: {
      client: `${baseDir}/config/webpack.client.config.js`,
      server: `${baseDir}/config/webpack.server.config.js`,
    },
    build: {
      host: 'localhost',
      port: 1592,
      path: 'build/',
      target: `${baseDir}/public/build`,
    },
  };

An configuration specified these optons:

ssr

Enable or disable server side side rendering. Disable ssr will improve start up speed.

i18n

app

  • app.name - The app name
  • app.shortName - The short app name.
  • app.port - App listening port.
  • app.routes - Customize koa routes.
  • app.middlewares - the js file that will apply your middlewares.

resources

  • resources.root - If resources.root is exist, kaon will serve all files inside the path as static server.

isomorphic

  • isomorphic.routes - The client routes path, should be an string, the default value is <project_root>/src/routes.
  • isomorphic.store - The client store path, should be an string, the default value is <project_root>/src/store/configureStore
  • isomorphic.main - The client entry

postcss

  • postcss.path - If use postcss, shoud specify postcss path.

webpack

  • webpack.client - your client webpack configuration, object or function. It will merge into default webpack configuration.
  • webpack.server - your server webpack configuration, object or function. It will merge into default webpack configuration.

build

  • build.host - The dev server will server at this host.
  • build.port - the dev server port.
  • build.path - the dev server url path.
  • build.target - the build result path.

command line

command: kaon <cmd> [options]

commands

kaon start [options]

available options:

  • config - specify config path

kaon build [options]

available options:

  • config - specify config path

nodejs APIs

You can use kaon as an node modules instead of cli.

const Kaon = require('kaon');
const kaon = new Kaon(config);

kaon.start();

build

const Kaon = require('kaon');
const kaon = new Kaon(config);

kaon.build();

environment variables

ENABLE_SSR

yes or no. If select yes, server side rendering will be enabled, no will disable server side rendering temporary.

apply your middleware.

First, configure your middleware path, it should be a javascript file like below:

const logger = require('koa-logger');
const favicon = require('koa-favicon');
const path = require('path');

function applyMiddlewares(app) {
  app.use(logger());
  app.use(favicon(path.join(__dirname, '../../public/favicon.ico')));
}

module.exports = applyMiddlewares;

The app instance will be passed to your function, then just call app.use to apply the middlewares.

apply your routes.

Just like apply middlewares. just don't forget configure your routes path in your config file.

const Router = require('koa-router');

function applyRoutes(app) {
  const router = new Router();

  router.get('/', async (ctx) => {
    ctx.body = 'hello world.';
  });

  app.use(router.routes());
  app.use(router.allowedMethods());
}

module.exports = applyRoutes;

add your customize script, styles, head tags, ect.

You can use react-helmet.

apply your own webpack configuration.

ATTENTION! You cannot override default entry with yours.

pm2 graceful reload

add the below configuration to your pm2

module.exports = {
  apps : [{
    name: "api",
    script: "./api.js",
    wait_ready: true,
    listen_timeout: 3000,
  }],
}

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].