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

react-gtfs-selector

v0.5.0

Published

React component to select a GTFS source via file drag-and-drop or online search

Readme

react-gtfs-selector

npm

A React component that lets users select a GTFS data source, either by dragging and dropping a local .zip file or by searching online GTFS feeds.

Live demo

| Import file | Online search | |:-----------:|:-------------:| | Import file tab | Search tab |

Install

npm install react-gtfs-selector

Usage

import { GtfsSelector, fileTab, urlTab, mobilityDataCsv, transportDataGouvFr } from 'react-gtfs-selector';
import 'react-gtfs-selector/style.css'; // optional — bundled default styles

function App() {
  return (
    <GtfsSelector
      onSelect={(result) => {
        if (result.type === 'file') {
          console.log('Got file:', result.fileName, result.blob);
        } else {
          console.log('Got URL:', result.title, result.url);
        }
      }}
      tabs={[mobilityDataCsv, transportDataGouvFr, fileTab, urlTab]}
    />
  );
}

The tabs prop controls exactly which tabs appear and in what order. Each entry is a GtfsTab object with id, label, and component.

Built-in tabs

  • fileTab — drag & drop or click to browse for a GTFS .zip file
  • urlTab — paste a direct GTFS feed URL
  • mobilityDataCsv — search the Mobility Database (CSV, no token needed)
  • transportDataGouvFr — search French public transit feeds
  • mobilityData — Mobility Database API (unavailable by default, needs token)

Examples

// Only file import and URL input
<GtfsSelector onSelect={handleSelect} tabs={[fileTab, urlTab]} />

// Only Mobility Database search
<GtfsSelector onSelect={handleSelect} tabs={[mobilityDataCsv]} />

// Custom order: sources first, then file, then URL
<GtfsSelector onSelect={handleSelect} tabs={[mobilityDataCsv, transportDataGouvFr, fileTab, urlTab]} />

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | onSelect | (result: GtfsSelectionResult) => void | required | Callback when a source is selected | | tabs | GtfsTab[] | required | Ordered list of tabs to display | | styled | boolean | true | Set to false to disable default CSS class names | | className | string | — | Additional CSS class on the root element |

Callback result

type GtfsSelectionResult =
  | { type: 'file'; blob: Blob; fileName: string }
  | { type: 'url'; url: string; title: string; gtfsRtUrls?: string[] };

transport.data.gouv.fr source

French public transit GTFS feeds. Datasets are cached in localStorage for 24h.

import { GtfsSelector, transportDataGouvFr, fileTab } from 'react-gtfs-selector';

<GtfsSelector onSelect={handleSelect} tabs={[transportDataGouvFr, fileTab]} />

Mobility Database sources

The CSV source works out of the box with no configuration:

import { GtfsSelector, mobilityDataCsv, fileTab } from 'react-gtfs-selector';

<GtfsSelector onSelect={handleSelect} tabs={[mobilityDataCsv, fileTab]} />

To use the API source, pass a configured instance with your token:

import { GtfsSelector, createMobilityDataSource, fileTab } from 'react-gtfs-selector';

const mobilityApi = createMobilityDataSource({ apiToken: 'your-token' });

<GtfsSelector onSelect={handleSelect} tabs={[mobilityApi, fileTab]} />

Custom sources

Implement the GtfsSource interface and wrap it with createSourceTab:

import { createSourceTab, fileTab } from 'react-gtfs-selector';
import type { GtfsSource } from 'react-gtfs-selector';

const mySource: GtfsSource = {
  id: 'my-source',
  label: 'My GTFS Provider',
  available: true,
  async fetchDatasets() { /* ... */ },
  search(datasets, query) { /* ... */ },
};

const myTab = createSourceTab(mySource);

<GtfsSelector onSelect={handleSelect} tabs={[myTab, fileTab]} />

Loading GTFS data

Once the user selects a source, use gtfs-sqljs to load and query the GTFS data:

import { GtfsSelector, fileTab, urlTab } from 'react-gtfs-selector';
import { GtfsSqlJs } from 'gtfs-sqljs';
import type { GtfsSelectionResult } from 'react-gtfs-selector';

function App() {
  const handleSelect = async (result: GtfsSelectionResult) => {
    let gtfs: GtfsSqlJs;

    if (result.type === 'url') {
      gtfs = await GtfsSqlJs.fromZip(result.url);
    } else {
      const data = await result.blob.arrayBuffer();
      gtfs = await GtfsSqlJs.fromZipData(data);
    }

    const routes = gtfs.getRoutes();
    console.log('Routes:', routes);

    gtfs.close();
  };

  return <GtfsSelector onSelect={handleSelect} tabs={[fileTab, urlTab]} />;
}

Styling

Import react-gtfs-selector/style.css for default styles. All CSS classes are prefixed with rgs-. Pass styled={false} to opt out entirely and provide your own styles.

Claude Code integration

This project includes a Claude Code skill file that provides Claude with detailed knowledge of the component API, source plugin pattern, and styling options. When working in a project that uses react-gtfs-selector, Claude Code will automatically suggest and guide integration.

Development

npm install
npm test        # run tests
npm run build   # build the library

License

MIT — Théophile Helleboid [email protected]