threepointone / rakt

fast websites, by default
291 stars 12 forks source link

rakt

[work in progress. come back when it's done!]

a framework, without any framework. for react/dialects. in a box.

usage


npm install rakt -g

quick start

make a script, say index.js

export default App = () => 
  <div>hello world</div>

then run

$ rakt index.js   

the big idea

one addition to react-router's <Route/> api

import { Route } from 'react-router'
- import User from './user.js'

<Route path='/user/:id'
-  component={User}
+  module='./user.js'
/>

behind the scenes, rakt handles code splitting + SSR + resource loading

optionally, use render/children as you normally would

<Route path='/user/:id'
  module='./user.js'
  render={ ({ Module }) => Module ? 
    <Module.Profile /> : 
    <span>loading...</span> )}
/>

defer

you can prevent ssr for a <Route/> with the defer attribute. great for starting apps faster, and offloading some work to the browser. rakt manages efficiently preloading code and/or data for the same.

<Route path='/user/:id' module='./user.js' defer />

todo - <Defer/>

leaf

[todo]

preserve

[todo]

data fetching

rakt takes data-fetching to the next level, by letting you colocate actual server side code alongside your component

import { initial } from 'rakt'

@initial(({ req, done }) => {    
  let db = require('mongo')(3111)
  db.get('users', req.params.id, done)  
  // gets removed from client side bundle(!)
})
export default class User {
  render(){
    return <div>
      {this.props.data || 'loading data'}
    </div>  
  }  
}

// augment this with your own solutions - relay, redux, etc

rakt will take care of efficiently fetching, hydration(for ssr), caching, etc

css

[todo]

rakt lets you write 'inline' css via glamor

<div css={{ color: 'red' }}>
  bloody valentine
</div>

prpl ootb

[todo]

rakt apps should conform to the prpl pattern without any extra work

cli

[todo]

rakt <script> <options>

rakt build <script> path/to/folder

options

integrating with other apps/frameworks

[todo]

you can take pieces from rakt and use them in your own app sans the rakt stack.

implementation

[todo]

constraints

todo -