Skip to content

enlightendesigns/ra-feathers-client

Repository files navigation

React Admin Feathersjs client

Feathers data and authentication provider to be used with react admin

Features

  • GET_LIST
  • GET_ONE
  • GET_MANY
  • GET_MANY_REFERENCE
  • CREATE
  • UPDATE
  • UPDATE_MANY (not supported)
  • DELETE
  • DELETE_MANY
  • AUTH_LOGIN
  • AUTH_LOGOUT
  • AUTH_CHECK
  • AUTH_ERROR
  • AUTH_GET_PERMISSION (not supported, see permission module

Actual installation

git clone https://github.com/room9/ra-feathers-client.git
cd ra-feathers-client
npm run build
npm link

cd /path/to/your/project
npm link ra-feathers-client

Installation (Not available yet)

npm install --save ra-feathers-client

or

yarn add ra-feathers-client

Usage

import React from 'react'
import feathers from '@feathersjs/client'
import { feathersDataProvider, feathersAuthProvider } from 'ra-feathers-client'

const host = 'http://localhost:3030'
const restClient = feathers.rest(host)
const client = feathers()
  // first configure the transport plugins
  .configure(restClient.fetch(window.fetch))
  // then configure the authentication
  .configure(feathers.authentication({
      jwtStrategy: 'jwt',
      storage: window.localStorage,
      storageKey: 'ra-feathers-token',
    }))

class App extends React.Component {
  render() {
    return (
      <Admin 
        dataProvider={feathersDataProvider(client)}
        authProvider={feathersAuthProvider(client)}
        ...
      >
       ...
      </Admin>
    )
  }
}

export default App

Important

The transports plugins (Rest, Socket, Primus...) must have been initialized previously to the authentication plugin. https://docs.feathersjs.com/api/authentication/client.html#appconfigureauthoptions