Real-time public transport departure information optimized for e-ink displays like Kindle.
- E-ink Optimized: High contrast black/white design, no gradients, thick borders
- Real-time Data: Live departure times from PTV (where available)
- Location Detection: Automatically detects nearby stops using browser geolocation
- Multi-stop Display: Show tram, train, and bus departures on one screen
- Configurable: Set your preferred stops via gear icon settings panel
- Multiple Refresh Strategies:
- Modern browsers: JavaScript-based auto-refresh
- Legacy devices (old Kindles):
<meta http-equiv="refresh">fallback
- Extensible Architecture: Provider pattern for easy addition of new transit systems
- Responsive: Works on any screen size
- 🚆 Melbourne trains (PTV)
- 🚊 Melbourne trams (PTV)
- 🚌 Melbourne buses (PTV)
- 🚐 V/Line coaches (PTV)
git clone https://github.com/astondg/next-departure.git
cd next-departure
npm installCopy the example environment file and add your PTV API credentials:
cp .env.example .env.localTo get PTV API credentials:
- Email
APIKeyRequest@ptv.vic.gov.auwith subject "PTV Timetable API - request for key" - You'll receive a developer ID and API key within a few days
npm run devOpen http://localhost:3000 - the app will try to detect your location and suggest nearby stops.
Add your PTV_DEV_ID and PTV_API_KEY as environment variables in Vercel.
The home page (/) provides:
- Automatic location detection to find nearby stops
- Gear icon settings panel to configure your tram, train, and bus stops
- Combined view showing departures from all configured stops
- Settings persistence in your browser's localStorage
Just tap the ⚙️ gear icon to configure your stops. The app will suggest nearby stops based on your location, or you can search manually.
For specific stops or shareable URLs, use /board/ptv/{stopId}:
/board/ptv/{stopId}?mode=tram&refresh=30&title=My%20Stop
Visit /setup to search for stops and generate URLs.
| Parameter | Description | Default |
|---|---|---|
mode |
Transport type: train, tram, bus |
All modes |
direction |
Filter by direction ID | All directions |
limit |
Maximum departures to show | 10 |
refresh |
Refresh interval in seconds | 30 |
title |
Custom display title | Stop name |
- Open Settings → Device Options → Advanced Options → Experimental Browser
- Navigate to your deployment URL
- Bookmark the page for easy access
For older Kindles without JavaScript support, the page automatically uses <meta http-equiv="refresh"> for updates.
Fetch departures from a stop.
GET /api/departures?provider=ptv&stopId=1234&mode=tram&limit=10
Search for stops by name.
GET /api/stops?provider=ptv&query=flinders&mode=train
Find stops near a location.
GET /api/nearby?provider=ptv&lat=-37.8136&lon=144.9631&mode=tram&distance=500
src/
├── app/
│ ├── api/
│ │ ├── departures/route.ts # Departures endpoint
│ │ ├── stops/route.ts # Stop search endpoint
│ │ └── nearby/route.ts # Location-based stop search
│ ├── board/[provider]/[stopId]/ # Dynamic board pages
│ ├── setup/ # URL setup page
│ ├── HomeClient.tsx # Main client component
│ └── page.tsx # Home page
├── components/
│ ├── CombinedBoard.tsx # Multi-stop display
│ ├── DepartureBoard.tsx # Single-stop display
│ ├── DepartureRow.tsx # Single departure
│ ├── SettingsModal.tsx # Configuration panel
│ ├── GearIcon.tsx # Settings icon
│ └── RefreshController.tsx # Auto-refresh logic
└── lib/
├── providers/
│ ├── types.ts # Common interfaces
│ ├── ptv/ # PTV implementation
│ └── index.ts # Provider registry
└── utils/
├── time.ts # Time formatting
└── storage.ts # Settings persistence
- Create a new directory in
src/lib/providers/(e.g.,translink/) - Implement the
TransitProviderinterface - Register in
src/lib/providers/index.ts
See src/lib/providers/types.ts for the full interface definition.
# Install dependencies
npm install
# Run development server
npm run dev
# Run linting
npm run lint
# Build for production
npm run build- TransLink (Queensland) support
- TfNSW (New South Wales) support
- Transport for London support
- Offline mode with service worker
- Multiple stops on one display
- Disruption alerts
MIT
- Data provided by Public Transport Victoria
- Built with Next.js and Tailwind CSS