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

jtcsv-vue

v1.0.0

Published

Vue 3 plugin, composables, and v-csv-upload directive for jtcsv.

Readme

jtcsv-vue

Current version: 0.1.0

Vue 3 plugin, composables, and v-csv-upload directive for jtcsv — the high-performance CSV/JSON toolkit. Imports from jtcsv/browser so File / Blob / FileReader APIs work out of the box in browser Vue apps.

The @jtcsv scope is squatted on npm — siblings ship unscoped (jtcsv-vue, jtcsv-excel, jtcsv-validator, jtcsv-codemod, jtcsv-tui).

Install

npm install jtcsv-vue jtcsv vue

jtcsv and vue are peer dependencies — see peerDependencies in package.json for supported ranges.

Quick start

Install the plugin (main.ts)

import { createApp } from 'vue';
import { createJtcsvPlugin } from 'jtcsv-vue';
import App from './App.vue';

const app = createApp(App);
app.use(createJtcsvPlugin());
app.mount('#app');

Use the composable (Composition API)

<template>
  <div>
    <input type="file" @change="handleFile" accept=".csv" />
    <pre>{{ data }}</pre>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useJtcsv } from 'jtcsv-vue';

const { csvToJson } = useJtcsv();
const data = ref<any[]>([]);

async function handleFile(event: Event) {
  const file = (event.target as HTMLInputElement).files?.[0];
  if (!file) return;
  const text = await file.text();
  data.value = csvToJson(text);
}
</script>

Use the v-csv-upload directive

<template>
  <input
    type="file"
    accept=".csv"
    v-csv-upload="{
      onLoad: handleData,
      onError: handleError,
      options: { delimiter: ',' },
    }"
  />
</template>

<script setup lang="ts">
function handleData(rows: any[], file: File) {
  console.log('Loaded', rows.length, 'rows from', file.name);
}
function handleError(err: Error, file: File) {
  console.error('Parse failed for', file.name, err);
}
</script>

Drag-and-drop upload with useCsvUpload

<template>
  <div
    @dragover="onDragOver"
    @dragleave="onDragLeave"
    @drop="onDrop"
    :class="{ dragging: isDragging }"
  >
    <p v-if="isParsing">Parsing…</p>
    <p v-else-if="error">{{ error.message }}</p>
    <p v-else>Drop a CSV file here</p>
  </div>
</template>

<script setup lang="ts">
import { useCsvUpload } from 'jtcsv-vue';

const { isParsing, error, isDragging, onDragOver, onDragLeave, onDrop } =
  useCsvUpload({
    onParsed: (rows, file) => console.log('Got', rows.length, 'rows'),
    onError: (err) => console.error(err),
  });
</script>

Download CSV

<script setup lang="ts">
import { useCsvDownload } from 'jtcsv-vue';

const { downloadCsv } = useCsvDownload();

function exportData() {
  downloadCsv(
    [{ name: 'alice', age: 30 }, { name: 'bob', age: 25 }],
    'users.csv',
  );
}
</script>

Plugin options

app.use(createJtcsvPlugin({
  async: true,            // expose csvToJsonAsync / jsonToCsvAsync (default: true)
  workers: false,         // reserved for worker support (default: false)
  propertyName: '$jtcsv', // global property name for Options API (default: '$jtcsv')
  provideComposable: true // also provide under the string key 'jtcsv' (default: true)
}));

API

createJtcsvPlugin(options?)

Returns a Vue Plugin. Call app.use(createJtcsvPlugin()). Registers the v-csv-upload directive and exposes a JtcsvVueInstance via both the jtcsvKey injection key and app.config.globalProperties.$jtcsv.

useJtcsv()

Composition API: returns the injected JtcsvVueInstance. Throws a helpful error if the plugin wasn't installed.

const { csvToJson, jsonToCsv } = useJtcsv();

useJtcsvAsync()

Composition API: like useJtcsv() but guarantees the async variants — if the plugin was installed with async: false they fall back to sync calls wrapped in Promise.resolve(...).

useCsvUpload({ parseOptions?, onParsed?, onError? })

Composable returning:

| key | type | description | | -------------- | --------------------------------------------- | ----------------------------------------------- | | isParsing | Ref<boolean> | true while parsing is in flight | | error | Ref<Error \| null> | last parse error | | isDragging | Ref<boolean> | true while a drag is hovering the drop zone | | handleFiles | (files: FileList \| File[]) => Promise<...> | parse the first file, fire callbacks | | onDragOver | (event: DragEvent) => void | wire to @dragover | | onDragLeave | (event: DragEvent) => void | wire to @dragleave | | onDrop | (event: DragEvent) => Promise<...> | wire to @drop |

Wraps parseCsvFile from jtcsv/browser.

useCsvDownload()

Returns { downloadCsv(data, filename?, options?) }. Wraps downloadAsCsv from jtcsv/browser.

v-csv-upload directive

Attach to a <input type="file">. Binding value:

{
  onLoad?: (data: any[], file: File) => void;
  onError?: (error: Error, file: File) => void;
  options?: CsvToJsonOptions;
}

jtcsvKey

InjectionKey<JtcsvVueInstance> (a Symbol.for('jtcsv')). Use with the explicit inject(jtcsvKey) form if you want type inference instead of calling useJtcsv().

Re-exported error classes

For convenient instanceof checks:

import {
  ValidationError,
  ParsingError,
  SecurityError,
  FileSystemError,
  LimitError,
  ConfigurationError,
  ERROR_CODES,
} from 'jtcsv-vue';

These are the exact same constructors exported by jtcsv/browser.

Options API

<template>
  <div>{{ $jtcsv.csvToJson(csv) }}</div>
</template>

<script>
export default {
  data() {
    return { csv: 'name,age\nalice,30' };
  },
};
</script>

Examples

See examples/basic-usage.ts for a runnable snippet.

License

MIT — see LICENSE.