Overview
@expresscsv/react gives you a hook-first API with reactive widget state and automatic cleanup on unmount.
Why Use React
- Works naturally inside React components
- Gives you reactive widget state like
isOpen,isReady, andlastError - Supports the same schema, chunking, webhook, theming, and localization features as the base SDK
- Fits cleanly into your existing component lifecycle and event handlers
Mental Model
- Define a schema with
x.row(). - Call
useExpressCSV()in your component. - Pass
schema,publishableKey, andimportIdentifier. - Trigger
open()from a user action. - Handle validated records with
onData,webhook, or both.
Basic Example
import { useExpressCSV, x } from "@expresscsv/react";
const productSchema = x.row({
name: x.string().label("Full Name"),
email: x.string().email().label("Email Address"),
});
export function ImportUsersButton() {
const { open, isReady } = useExpressCSV({
schema: productSchema,
publishableKey: "pk_test_...",
importIdentifier: "user-import",
title: "Import users",
});
return (
<button
type="button"
disabled={!isReady}
onClick={() =>
open({
onData: (chunk, next) => {
console.log(chunk.records);
next();
},
})
}
>
Import Users
</button>
);
}Next Steps
- Build your first import in Quickstart
- Types — define field types, validation rules, and TypeScript types
- Styling — theme the widget to match your app
- Webhooks — deliver records to your backend
- API Reference — full option and return value reference