A JS library for your client store, server querying, database management

Simple API



From the client to the server, every aspect of the API is designed to be minimal and abstract a lot of boilerplate away.


  run('getMessages')
    .then(data => set({ messages: data.response }))
    .catch(error => console.log(error))
          

Client Side Store



  
  set({ username: 'didrio', id: 1 })

  const username = get('username')
          

A single, central store that triggers React renders when updated from any component.

Single Server Endpoint



All server communication is handled through a single Web Socket connection without the need for RESTful routes.

          
  run('getMessages')
    .then(data => set({ messages: data.messages }))
    .catch(error => console.log(error))

  run('postMessage', { message: 'ok', userid: 1 })
          

SQL And More



            
  const actions = {
    getMessages: {
      action: 'SELECT * FROM posts'
    },
    getWeather: {
      action: (resolve, reject, request) => { 
        fetch(request.url, (error, response, body) => { 
          if (error) reject(error); 
          else resolve(body);
        }); 
      }
    }
  }
          

Server actions can be SQL query strings or just arbitrary functions that call to any API, and the response automatically gets sent back to the client.

Client Subscriptions



Clients can listen for server actions triggered by other clients, allowing for real-time data updates.


  on('getMessages', data => set('messages', data.messages))

  emit('getMessages')
          

Time Travel Debugging



Since the client store is built upon Redux, the Redux DevTools work out of the box.

Getting Started



React

    
  npm install react-agent --save
          

  import { Agent } from 'react-agent'

  render(
    <Agent>
      <App />
    </Agent>
  , document.querySelector('#root'))
          

Node / Express

    
  npm install react-agent-server --save
          

  const agent = require('react-agent-server') 

  const server = app.listen(3000) 
  
  const actions = { 
    getMessages: { 
      action: 'SELECT * FROM posts' 
    } 
  } 

  const database = { 
    name: 'react', user: 'agent', password: 'ra', 
    dialect: 'postgres', host: 'db.com', port: 3421 
  }
  
  agent(server, actions, database)
          

Our Team



Tom Rosenblatt

Software Engineer

Henry Au

Software Engineer

Andrew Harris

Software Engineer

Eric Choi

Software Engineer