
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
react-csvify
Advanced tools
A composable, extensible, and fully typed React component for generating and downloading CSV files from any dataset.
A production-ready, composable, and fully typed React component for generating and downloading CSV, TSV, and JSON files from any dataset. Designed for advanced customization, zero dependencies, and seamless integration into modern React or Next.js applications.
npm install react-csvify@latest
# or
yarn add react-csvify@latest
# or
pnpm add react-csvify@latest
| Requirement | Version | Notes |
|---|---|---|
| React | 16+ | Hooks-based components |
| React DOM | 16+ | Standard DOM rendering |
| TypeScript | 4.5+ | Recommended for best experience |
| Node.js | 16+ | For development and building |
Note: This package has
reactandreact-domas peer dependencies. Ensure they're already installed in your project.
"use client";
import React from "react";
import { DownloadButton } from "react-csvify";
interface User {
id: number;
name: string;
email: string;
}
export default function BasicExample() {
const users: User[] = [
{ id: 1, name: "Alice Johnson", email: "alice@example.com" },
{ id: 2, name: "Bob Smith", email: "bob@example.com" },
{ id: 3, name: "Carol Davis", email: "carol@example.com" },
];
return (
<DownloadButton
data={users}
filename="users.csv"
/>
);
}
import { DownloadButton } from "react-csvify";
export default function MultiFormatExample() {
const data = [
{ id: 1, name: "Alice", active: true },
{ id: 2, name: "Bob", active: false },
];
return (
<div className="space-y-4">
{/* Export as CSV */}
<DownloadButton data={data} filename="data.csv" />
{/* Export as TSV */}
<DownloadButton data={data} filename="data.tsv" />
{/* Export as JSON */}
<DownloadButton data={data} filename="data.json" />
</div>
);
}
"use client";
import React, { useState } from "react";
import {
DownloadButton,
validateCsvData,
formatCsvValue,
parseCSV,
} from "react-csvify";
export default function AdvancedExample() {
const [validationErrors, setValidationErrors] = useState<string[]>([]);
const data = [
{ id: 1, name: "Alice", joinDate: "2024-01-15", score: 95.5 },
{ id: 2, name: "Bob", joinDate: "2024-02-20", score: 88.3 },
];
const handleDownload = () => {
// Validate before download
const validation = validateCsvData(data, {
maxRows: 10000,
maxFieldSize: 5000,
allowEmpty: false,
});
if (!validation.valid) {
setValidationErrors(validation.errors);
return;
}
setValidationErrors([]);
};
return (
<div>
{validationErrors.length > 0 && (
<div className="error-box">
{validationErrors.map((err, idx) => (
<p key={idx}>{err}</p>
))}
</div>
)}
<DownloadButton
data={data}
filename="users.csv"
transformValue={(value, key) => {
if (key === "score" && typeof value === "number") {
return value.toFixed(1);
}
return String(value);
}}
onDownloadStart={handleDownload}
customButton={
<button className="bg-blue-500 text-white px-4 py-2 rounded">
Export CSV
</button>
}
/>
</div>
);
}
The main React component for triggering downloads.
<DownloadButton
data={users}
filename="export.csv"
customHeaders={["ID", "Full Name", "Email"]}
transformValue={(value, key, row) => {
// Custom formatting
if (key === "joinDate") {
return new Date(value as string).toLocaleDateString();
}
return String(value);
}}
onDownloadStart={() => console.log("Starting...")}
onProgress={(progress) => console.log(`${progress.percentage}% complete`)}
onDownloadComplete={() => console.log("Done!")}
onError={(error) => console.error(error)}
/>
Parse CSV strings back to objects:
import { parseCSV, parseTSV, detectDelimiter } from "react-csvify";
const csvContent = `id,name,email
1,Alice,alice@example.com
2,Bob,bob@example.com`;
const result = parseCSV(csvContent);
if (result.success) {
console.log(result.data); // Typed array of objects
}
// Auto-detect delimiter
const delimiter = detectDelimiter(csvContent);
Validate data before export:
import { validateCsvData, detectDataIssues } from "react-csvify";
const validation = validateCsvData(data, {
maxRows: 10000,
allowEmpty: false,
});
if (!validation.valid) {
console.error("Validation errors:", validation.errors);
}
// Detect potential issues
const issues = detectDataIssues(data);
Format & transform values:
import { formatCsvValue, formatCsvRow } from "react-csvify";
const formatted = formatCsvValue("Hello, World", true);
console.log(formatted.formatted); // "Hello, World"
const row = formatCsvRow(
["id", "name", "active"],
",",
true
);
import {
generateContent,
generateContentWithProgress,
} from "react-csvify";
// Simple generation
const csv = generateContent(data, "csv", {
delimiter: ",",
quoteValues: true,
customHeaders: ["ID", "Name"],
});
// With progress tracking
generateContentWithProgress(
largeDataset,
"json",
(progress) => {
console.log(`Processing: ${progress.percentage}%`);
},
{ prettifyJson: true }
);
See EXAMPLES.md for:
| Prop | Type | Default | Description |
|---|---|---|---|
data | T[] | Required | Array of objects to export |
filename | string | Required | Output filename (extension determines format) |
delimiter | string | "," | Field delimiter (CSV only) |
quoteValues | boolean | true | Wrap values in quotes |
transformValue | (value, key, row) => string | – | Custom value formatter |
customHeaders | string[] | – | Override auto-generated headers |
customButton | ReactNode | – | Custom trigger button/component |
emptyDataMessage | string | "No data available." | Message when data is empty |
onDownloadStart | () => void | – | Called before generation |
onDownloadComplete | () => void | – | Called after successful download |
onError | (error: Error) => void | – | Error handler |
onProgress | (progress) => void | – | Progress callback for large datasets |
chunkSize | number | 1000 | Rows processed before progress update |
Contributions are welcome! Please see CONTRIBUTING.md for details.
See CHANGELOG.md for version history and updates.
We use Semantic Versioning. Current version: 1.1.0
This project is licensed under the ISC License - see the LICENSE file for details.
This project adheres to the Contributor Covenant Code of Conduct.
If you find this library helpful:
Your support keeps this project maintained and improved! 🚀
Made with ❤️ by ninsau
FAQs
A composable, extensible, and fully typed React component for generating and downloading CSV files from any dataset.
We found that react-csvify demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.