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

@pubflow/next

v0.1.5

Published

A standardized API integration system for Pubflow Bridge Next.js applications

Downloads

8

Readme

PubFlow

A standardized API integration system for Next.js applications. This library provides components for API handling, authentication, and CRUD operations with the Bridge API pattern.

Features

  • API Client: Standardized API request handling with session management
  • Authentication: User authentication and route protection
  • Bridge API: Reusable CRUD operations for API endpoints
  • Validation: Zod-based validation utilities

Installation

# If you're using npm
npm install @pubflow/next

# If you're using yarn
yarn add @pubflow/next

# If you're using bun
bun add @pubflow/next

Usage

API Client

import { api } from '@pubflow/next';

// Make a GET request
const response = await api.get('/users');

// Make a POST request
const createResponse = await api.post('/users', { name: 'John Doe' });

// Make a PUT request
const updateResponse = await api.put('/users/123', { name: 'Jane Doe' });

// Make a DELETE request
const deleteResponse = await api.delete('/users/123');

Authentication

// In your _app.tsx or layout.tsx
import { AuthProvider } from 'pubflow';

function MyApp({ Component, pageProps }) {
  return (
    <AuthProvider>
      <Component {...pageProps} />
    </AuthProvider>
  );
}

// In your components
import { useAuth } from '@pubflow/next';

function ProfilePage() {
  const { user, isLoading, logout } = useAuth();
  
  if (isLoading) return <div>Loading...</div>;
  
  return (
    <div>
      <h1>Welcome, {user?.name}</h1>
      <button onClick={logout}>Logout</button>
    </div>
  );
}

// Protect routes
import { RouteGuard } from '@pubflow/next';

function AdminPage() {
  return (
    <RouteGuard allowedTypes={['admin', 'superadmin']}>
      <div>Admin content</div>
    </RouteGuard>
  );
}

Bridge API

import { useBridgeCrud } from '@pubflow/next';
import { z } from 'zod';

// Define validation schema
const userSchema = z.object({
  id: z.string(),
  name: z.string().min(2),
  email: z.string().email(),
  role: z.enum(['user', 'admin']),
});

function UserList() {
  const { 
    items, 
    loading, 
    error, 
    createItem, 
    updateItem, 
    deleteItem,
    searchTerm,
    setSearchTerm
  } = useBridgeCrud({
    entityConfig: {
      endpoint: 'users'
    },
    schemas: {
      entity: userSchema
    },
    successMessages: {
      create: 'User created successfully',
      update: 'User updated successfully',
      delete: 'User deleted successfully'
    }
  });
  
  if (loading) return <div>Loading...</div>;
  if (error) return <div>Error: {error}</div>;
  
  return (
    <div>
      <input 
        type="text" 
        value={searchTerm} 
        onChange={(e) => setSearchTerm(e.target.value)}
        placeholder="Search users..."
      />
      
      <ul>
        {items.map(user => (
          <li key={user.id}>
            {user.name} ({user.email})
            <button onClick={() => deleteItem(user.id)}>Delete</button>
          </li>
        ))}
      </ul>
      
      <button onClick={() => createItem({ name: 'New User', email: '[email protected]', role: 'user' })}>
        Add User
      </button>
    </div>
  );
}

Validation

import { validateWithZod, showValidationErrors } from 'pubflow';
import { z } from 'zod';

// Define validation schema
const formSchema = z.object({
  name: z.string().min(2, 'Name must be at least 2 characters'),
  email: z.string().email('Invalid email address'),
  age: z.number().min(18, 'Must be at least 18 years old')
});

// Validate data
function handleSubmit(data) {
  const validation = validateWithZod(formSchema, data);
  
  if (!validation.success) {
    showValidationErrors(validation.errors || {});
    return;
  }
  
  // Proceed with valid data
  const validData = validation.data;
  // ...
}

Documentation

For more detailed documentation, see the following guides:

Session Validation

The package includes a configurable session validation feature that ensures user sessions are regularly validated and automatically redirects users to the login page when their session expires:

// Configure session validation
const PUBFLOW_CONFIG = {
  API_URL: 'https://api.example.com',
  sessionConfig: {
    validationInterval: 10 * 60 * 1000, // 10 minutes
    validationEndpoint: '/validation',  // Endpoint for validation
    autoValidate: true                  // Enable automatic validation
  }
};

// Make the configuration available to @pubflow/next
window.__PUBFLOW_CONFIG = PUBFLOW_CONFIG;

For more details, see the Session Validation Guide.