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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@fluxwp/plugin-kit

v0.1.2

Published

Build wp-admin React screens for your WordPress plugin: Vite preset, typed GraphQL codegen, persisted queries, shared runtime.

Readme

@fluxwp/plugin-kit

npm license

Build wp-admin screens for your WordPress plugin in React and TypeScript, with typed GraphQL (WPGraphQL) queries, persisted queries and server-side preloaded data. Your screens open inside the same fast single-page admin shell as the FluxWP plugins: no page reload between screens, light / dark theme, translations.

  • Tiny bundles. React, React Query, i18next and the FluxWP UI kit come from a shared runtime that the Flux GraphQL plugin loads once per page. A plugin screen is usually a few KB.
  • End-to-end types. flx-kit codegen turns your .graphql operations into TypeScript types and ready-to-use operation constants, checked against the site's schema.
  • Fast first paint. PHP preloads the first query, so the screen renders without a spinner.
  • Vite preset. fluxScreens() does the wiring: runtime imports, scoped CSS, code splitting.

Needs the Flux GraphQL plugin (flx-graphql 0.5 or newer) on the WordPress site.

Install

npm i -D @fluxwp/plugin-kit react @tanstack/react-query react-i18next typescript vite
# or: bun add -d … / pnpm add -D …

Project layout

my-plugin/
  my-plugin.php                         registers the screen and the persisted queries (below)
  graphql/operations/FlxMyOrders.graphql
  graphql/schema.graphql                your own GraphQL types, if the plugin registers any
  screens/index.ts                      export const screens = { 'my-orders': () => import('./Orders') }
vite.config.ts
// vite.config.ts
import { fluxScreens } from '@fluxwp/plugin-kit/vite';

export default fluxScreens({ entry: 'my-plugin/screens/index.ts', outDir: 'my-plugin/assets/flux' });
# my-plugin/graphql/operations/FlxMyOrders.graphql
query FlxMyOrders {
  viewer { name }
}
npx flx-kit codegen my-plugin   # → screens/generated/{types,operations}.ts + graphql/persisted-queries.json
npx vite build                  # → assets/flux/flux-screens.js (+ chunks, css, chunks.json)

A screen

// my-plugin/screens/Orders.tsx
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { createGraphQLClient } from '@fluxwp/graphql';
import { FlxGraphQLProvider, useFlxQuery } from '@fluxwp/graphql/react';
import { useHost } from '@fluxwp/host';
import { Loading } from '@fluxwp/ui';
import { FlxMyOrders } from './generated/operations';

export default function Orders() {
  const host = useHost();
  const client = useMemo(() => createGraphQLClient({ api: host.client }), [host.client]);
  return (
    <FlxGraphQLProvider client={client} scope={host.scope}>
      <Hello />
    </FlxGraphQLProvider>
  );
}

function Hello() {
  const { t } = useTranslation('my');
  const q = useFlxQuery(FlxMyOrders, {}); // q.data is typed from the schema
  if (!q.data) return <Loading />;
  return <h1>{t('hello', { name: q.data.viewer?.name })}</h1>;
}

screens/index.ts may also export resources ({ en: { my: { hello: 'Hello {{name}}' } }, tr: { … } }) for i18next.

PHP side

add_filter( 'flx_gql_persisted_manifests', function ( $m ) {
	$m['my-plugin'] = __DIR__ . '/graphql/persisted-queries.json';
	return $m;
} );

add_action( 'admin_menu', function () {
	add_menu_page( 'Orders', 'Orders', 'read', 'my-orders', function () {
		if ( function_exists( 'flx_admin_screen_render' ) && flx_admin_screen_render() ) {
			return;
		}
		echo 'This screen needs the Flux GraphQL plugin.';
	} );
	if ( function_exists( 'flx_admin_screen' ) ) {
		flx_admin_screen( 'my-orders', array(
			'module'     => 'my-orders',
			'assets_dir' => __DIR__ . '/assets/flux/',
			'assets_url' => plugin_dir_url( __FILE__ ) . 'assets/flux/',
			'preload'    => array( array( 'FlxMyOrders' ) ), // first data ships with the page
		) );
	}
}, 20 );

Your own GraphQL types

Register them in PHP with the Flux GraphQL kit (flx_gql_type, flx_gql_query, flx_gql_mutation on flx_gql_register; every field declares a capability). To type-check your screens against them, export the schema of a site with your plugin active and keep your part in the plugin:

wp flx-gql schema --output=schema.graphql --owners=owners.json
npx flx-kit schema-split schema.graphql owners.json my-plugin   # → my-plugin/graphql/schema.graphql

CLI

| Command | Does | |---|---| | flx-kit codegen <plugin-dir> [--check] | Types, operation constants and persisted-queries.json for the plugin's operations (--check: fail if out of date, for CI) | | flx-kit schema-split <schema> <owners> <plugin-dir> | Writes the plugin's own part of a site schema |

Rules

  • Import only what the runtime provides: react, react/jsx-runtime, react-dom, react-dom/client, @tanstack/react-query, i18next, react-i18next, @fluxwp/core, @fluxwp/tokens, @fluxwp/ui, @fluxwp/graphql, @fluxwp/graphql/react, @fluxwp/host. Anything else is bundled with your screens; other @fluxwp/* imports fail the build.
  • Operation names start with Flx (FlxMyOrders), one operation per file. Prefix screen ids with your plugin (acme-orders).
  • Your CSS is scoped under .flux-root; the @fluxwp/ui styles are already on the page.

Complete example plugin: example/acme-hello.

The FluxWP packages

| Package | What it is | |---|---| | @fluxwp/plugin-kit | Build wp-admin React screens for your own WordPress plugin (Vite preset + flx-kit codegen) | | @fluxwp/graphql | Typed GraphQL client and React hooks for Flux GraphQL (WPGraphQL) | | @fluxwp/host | Host context of a screen: site client, user, locale | | @fluxwp/ui | React UI kit of FluxWP screens: Check, DatePicker, Modal, Icon … | | @fluxwp/core | WordPress REST client, sign-in (OAuth PKCE, app passwords), accounts, i18n | | @fluxwp/tokens | Design tokens: colours, spacing, radius, type, light / dark |

FluxWP is an open-source, all-in-one WordPress suite (donations, forms, e-commerce, CRM, e-mail, AI, SEO) with a desktop and mobile app. Source: github.com/FluxWP/FluxWP. Questions and ideas: [email protected].

License

GPL-2.0-or-later