CSVJetty

Docs

Home
Dashboard

Get started

React

Receive data

Get started

React CSV importer

Add a CSV import flow to React with the CSVJetty component, then receive validated records in an onData callback.

View as Markdown

On this page

InstallBasic usageSave imported recordsImporter lifecycleRequirements

CSVJetty is a React component that opens the configured importer inside your application and delivers imported records back to your code.

CSVJetty file upload interface in the demo
The recording uses older CSV/TSV wording; current supported uploads are CSV files.

Install

BASH

npm install csvjetty

CSVJetty supports React 18 and React 19. Create an importer in the dashboard before integrating so you have an importer key to pass to the component. If the importer model is new to you, read Importers first.

Basic usage

ImportContacts.jsx

import CSVJetty from "csvjetty";
export default function ImportContacts() {  return (    <CSVJetty      importerKey="YOUR_IMPORTER_KEY"      onData={async ({ rows }) => {        console.log(rows);      }}    >      Import contacts    </CSVJetty>  );}

The component renders its children as the launch button. Clicking it opens the importer in a modal without navigating away from your application.

Save imported records

In production, send records from onData to an authenticated API you control. Validate the records again on the server before writing them to your database.

ImportContacts.jsx

import CSVJetty from "csvjetty";
export default function ImportContacts() {  return (    <CSVJetty      importerKey="YOUR_IMPORTER_KEY"      onData={async ({ rows, importId, rowNumbers }) => {        const response = await fetch("/api/contacts/import", {          method: "POST",          headers: { "Content-Type": "application/json" },          body: JSON.stringify({ rows, importId, rowNumbers }),        });
        if (!response.ok) {          throw new Error("Could not save contacts.");        }
        const body = await response.text();        return body ? JSON.parse(body) : undefined;      }}      onComplete={({ importId, accepted, rejected }) => {        console.log({ importId, accepted, rejected });      }}    >      Import contacts    </CSVJetty>  );}

Make writes idempotent

CSVJetty can retry delivery. Use importId together with the original row numbers to avoid creating duplicate records if your application receives the same work more than once.

See Callback delivery for row-level errors and Import payload for the exact fields you receive.

Importer lifecycle

  • onData runs when callback delivery is ready to save a batch of rows.
  • onComplete receives the final import ID and accepted/rejected counts.
  • onClose runs when the importer modal closes.
  • Throw from onData when the batch could not be saved.
  • Return row-level errors from onData when only specific records should be rejected.

The complete prop contract is in CSVJetty component props.

Requirements

  • React 18 or 19.
  • A public CSVJetty importer key.
  • An onData handler when the importer uses callback delivery.
  • HTTPS in production; localhost is supported for local development.

See Limits & requirements for file, row, and plan limits.