https://github.com/lirbank/google-calendar-url
Generate shareable URLs for adding Google Calendar events
https://github.com/lirbank/google-calendar-url
calendar google-calendar google-calendar-api typescript
Last synced: 8 months ago
JSON representation
Generate shareable URLs for adding Google Calendar events
- Host: GitHub
- URL: https://github.com/lirbank/google-calendar-url
- Owner: lirbank
- License: mit
- Created: 2020-03-16T17:58:56.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2025-06-21T02:03:51.000Z (12 months ago)
- Last Synced: 2025-08-09T07:26:00.794Z (10 months ago)
- Topics: calendar, google-calendar, google-calendar-api, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/google-calendar-url
- Size: 172 KB
- Stars: 15
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Google Calendar URL
Generate shareable URLs for adding Google Calendar events.
## Features
- 📦 **No dependencies** - Lightweight and self-contained
- 🛡️ **TypeScript native** - Written in TypeScript with strict type definitions
- 🌐 **Universal compatibility** - Works with JavaScript and TypeScript
## Installation
```sh
bun add google-calendar-url
pnpm add google-calendar-url
yarn add google-calendar-url
npm install google-calendar-url
```
## Usage
```ts
import { googleCalendarEventUrl } from "google-calendar-url";
// Compact ISO 8601 format
googleCalendarEventUrl({
start: "20201212T100000Z",
end: "20201212T110000Z",
title: "Event title",
details: "Event details",
location: "San Francisco",
});
// Extended ISO 8601 format
googleCalendarEventUrl({
start: "2020-12-12T10:00:00Z",
end: "2020-12-12T11:00:00Z",
title: "Event title",
details: "Event details",
location: "San Francisco",
});
// Output (same for both):
// https://calendar.google.com/calendar/event?action=TEMPLATE&dates=20201212T100000Z%2F20201212T110000Z&text=Event+title&details=Event+details&location=San+Francisco
```
[Try the URL ](https://calendar.google.com/calendar/event?action=TEMPLATE&dates=20201212T100000Z%2F20201212T110000Z&text=Event+title&details=Event+details&location=San+Francisco)
## Helper function
The `toGoogleCalendarDate()` helper converts JavaScript `Date` objects to Google Calendar date strings.
```ts
import { toGoogleCalendarDate } from "google-calendar-url";
const date = new Date("2024-03-21T14:30:45Z");
// All-day event
toGoogleCalendarDate(date, { source: "utc", style: "allDay" });
// "20240321"
// Time in user's local timezone (floating)
toGoogleCalendarDate(date, { source: "local", style: "floating" });
// "20240321T143045" (varies by timezone)
// UTC time (instant)
toGoogleCalendarDate(date, { source: "utc", style: "instant" });
// "20240321T143045Z"
googleCalendarEventUrl({
start: toGoogleCalendarDate(date, { source: "utc", style: "allDay" }),
end: toGoogleCalendarDate(date, { source: "utc", style: "allDay" }),
title: "Event title",
details: "Event details",
location: "San Francisco",
});
```
**Options:**
- `source`: `"utc"` | `"local"` - Whether to read the date in UTC or local time
- `style`: `"allDay"` | `"floating"` | `"instant"` - How Google Calendar should interpret the date
## References
- [Unofficial spec](https://github.com/InteractionDesignFoundation/add-event-to-calendar-docs/blob/master/services/google.md)
## Contributing
Contributions are welcome! Please open issues or pull requests on [GitHub](https://github.com/lirbank/google-calendar-url/pulls).
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Need expert help?
Hi, I'm [@lirbank](https://github.com/lirbank). I take on a few consulting projects each year where I help companies build, unblock, and ship. Here's what I do:
**[STΛR MODΞ](https://www.starmode.dev/)** — A boutique AI development studio I run with AI/ML expert and data scientist [@spencer-g-smith](https://github.com/spencer-g-smith). We help companies build accurate AI solutions: AI-first apps, advanced workflows, and agentic systems.
**[Mikael Lirbank](https://www.lirbank.com/)** — My solo practice, focused on web app development, test automation, code quality, and technical architecture. I'm friendly and happy to help with the hard stuff.