[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
make a script, say index.js
export default App = () =>
<div>hello world</div>
then run
$ rakt index.js
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> )}
/>
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/>
[todo]
[todo]
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
@get
, @post
, @put
, @del
@socket
, @sse
, @memory
, etc [todo]
rakt lets you write 'inline' css via glamor
<div css={{ color: 'red' }}>
bloody valentine
</div>
[todo]
rakt apps should conform to the prpl pattern without any extra work
[todo]
rakt <script> <options>
rakt build <script> path/to/folder
options
ssr
- server side rendering - default true
splits
- code splits - default true
production
- production mode - default false
css
- 'inline' css - default true
[todo]
you can take pieces from rakt and use them in your own app sans the rakt stack.
<Layout/>
[todo]
module
must be a string literalmodule
, path
must be a string literaltodo -
<Route/>
, <Link/>
, etc