npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ra-strapi

v1.0.3

Published

Data provider for React Admin using Strapi

Downloads

69

Readme

ra-strapi

This package provides a Data Provider and an Auth Provider to integrate Strapi with react-admin.

This package supports:

  • CRUD on Documents
  • Authentication with email and password

Installation

yarn add ra-strapi
# or
npm install ra-strapi

Usage

Using the public API

Create a new dataprovider giving the baseURL of your Strapi instance, pass the dataprovider to the Admin component.

import { strapiDataProvider } from "ra-strapi";
import { Admin, ListGuesser, Resource } from "react-admin";
import { Layout } from "./Layout";

const dataProvider = strapiDataProvider({ baseURL: "http://localhost:1337" });

export const App = () => (
  <Admin layout={Layout} dataProvider={dataProvider}>
    <Resource name="articles" list={ListGuesser} />
  </Admin>
);

note: you may need to tune the permissions of the public role ( see Strapi doc ).

Using the authenticated API

Create an authProvider giving the baseURL of your Strapi instance, it will handle for you the jwt token. Create an httpClient with strapiHttpClient, it will handle the authorization headers for you. Create a dataProvider giving the baseURL of your Stapi instance, and the httpClient you created. Pass those dataProvider and authProvider to you Admin component. As you will need to authenticate with email/password, pass the react-admin LoginWithEmail to the loginPage prop, or a custom login page.

import {
  strapiDataProvider,
  strapiAuthProvider,
  strapiHttpClient,
} from "ra-strapi";
import { Admin, ListGuesser, LoginWithEmail, Resource } from "react-admin";
import { Layout } from "./Layout";

const STRAPI_URL = import.meta.env.VITE_STRAPI_URL;
const authProvider = strapiAuthProvider({ baseURL: STRAPI_URL });
const httpClient = strapiHttpClient();
const dataProvider = strapiDataProvider({ baseURL: STRAPI_URL, httpClient });
export const App = () => (
  <Admin
    layout={Layout}
    dataProvider={dataProvider}
    authProvider={authProvider}
    loginPage={LoginWithEmail}
  >
    <Resource name="articles" list={ListGuesser} />
  </Admin>
);

Using an API key

Create an httpClient with strapiHttpClient, specifying the authType to apiKey and the key. Create a dataProvider giving the baseURL of your Stapi instance, and the httpClient you created.

import { strapiDataProvider, strapiHttpClient } from "ra-strapi";
import { Admin, ListGuesser, LoginWithEmail, Resource } from "react-admin";
import { Layout } from "./Layout";

const STRAPI_URL = import.meta.env.VITE_STRAPI_URL;
const STRAPI_API_KEY = import.meta.env.VITE_STRAPI_API_KEY;
const httpClient = strapiHttpClient({ authType: "apiKey", apiKey:  STRAPI_API_KEY});
const dataProvider = strapiDataProvider({ baseURL: STRAPI_URL, httpClient });
export const App = () => (
  <Admin layout={Layout} dataProvider={dataProvider} loginPage={LoginWithEmail}>
    <Resource name="articles" list={ListGuesser} />
  </Admin>
);

note: you may need to create an api key in the Strapi admin panel ( see Strapi doc ).

Filtering

To learn how filter works with react-admin refer to the documentation here. The availables filters operators are : | Operator | Description | | ---------- | ---------------------------- | | eq | equal | | eqi | equal (case insensitive) | | ne | not equal | | nei | not equal (case insensitive) | | gt | greater than | | gte | greater than or equal | | lt | less than | | lte | less than or equal | | contains | contains | | ncontains | not contains | | containsi | contains (case insensitive) | | ncontainsi | not contains (case insensitive) | | between | between two values | | in | in an array | | nin | not in an array | | isnull | is null | | isnotnull | is not null | | startswith | starts with | | startswithi| starts with (case insensitive) | | endswith | ends with | | endswithi | ends with (case insensitive) |

import {
  Datagrid,
  ImageField,
  List,
  ReferenceField,
  TextField,
  TextInput
} from "react-admin";

const articleFilters = [
  <TextInput source="title_contains" label="Title"/> // will filter articles with title containing the value
]

export const ArticleList = () => (
  <List filters={articleFilters}>
    <Datagrid>
      <ImageField source="cover.formats.thumbnail.url" label="Cover" />
      <TextField source="title" />
      <TextField source="description" />
      <ReferenceField reference="authors" source="author" link="show" />
      <ReferenceField reference="categories" source="category" link="show" />
    </Datagrid>
  </List>
);

License

MIT