# generate-ical

> A lightweight, typed utility for generating iCal files and calendar URLs. With minimal dependencies and minimal code complexity, this can be used almost everywhere.

Latest version **2.0.0** (published 2025-12-22) · 0 weekly downloads

## Install

```sh
npm install generate-ical
pnpm add generate-ical
yarn add generate-ical
bun add generate-ical
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2025-12-22 |
| First published | 2022-12-06 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Lukas Wiklund |
| Maintainers | lukaswiklund |

## Links

- npm: https://www.npmjs.com/package/generate-ical
- Repository: https://github.com/lukaswiklund/generate-ical
- Homepage: https://github.com/lukaswiklund/generate-ical#readme
- Issues: https://github.com/lukaswiklund/generate-ical/issues
- npm.io page: https://npm.io/package/generate-ical

## Dependencies (1)

- [uuid-random](https://npm.io/package/uuid-random.md) ^1.3.2

## Recent versions

- 2.0.0 (latest) — 2025-12-22
- 1.0.7 — 2025-03-03
- 1.0.6 — 2025-03-03
- 1.0.5 — 2022-12-06
- 1.0.4 — 2022-12-06
- 1.0.3 — 2022-12-06
- 1.0.2 — 2022-12-06
- 1.0.1 — 2022-12-06
- 1.0.0 — 2022-12-06

## README

# generate-ical

A lightweight, typed utility for generating iCal files and calendar URLs. With minimal dependencies and minimal code complexity, this can be used almost everywhere.

It doesn't depend on any specific implementation (e.g., Express, Koa, file system, etc.). It simply generates the file content as a string for you to use however you want.

## Install

`npm install generate-ical`

## Functions

### `generateIcal`

Generates an iCal file content as a string.

```typescript
import { generateIcal } from "generate-ical"

const fileContent = generateIcal({
	title: "My First Event",
	description: {
		plain: "My event description",
		html: "<p>My event description <b>formatted with HTML</b></p>",
	},
	isAllDay: false,
	startDate: new Date("2023-01-01T18:00:00.000Z"),
	endDate: new Date("2023-01-01T22:00:00.000Z"),
	location: { title: "My place" },
	url: "https://optional-video-call.com",
	organizer: { name: "Lukas Wiklund" },
})
```

### `generateGoogleUrl`

Generates a Google Calendar URL for adding an event.

```typescript
import { generateGoogleUrl } from "generate-ical"

const googleUrl = generateGoogleUrl({
	title: "My First Event",
	description: {
		plain: "My event description",
	},
	isAllDay: false,
	startDate: new Date("2023-01-01T18:00:00.000Z"),
	endDate: new Date("2023-01-01T22:00:00.000Z"),
	location: { title: "My place" },
	url: "https://optional-video-call.com",
})
```

### `generateOffice365Url`

Generates an Office 365 Calendar URL for adding an event.

```typescript
import { generateOffice365Url } from "generate-ical"

const office365Url = generateOffice365Url({
	title: "My First Event",
	description: {
		plain: "My event description",
	},
	isAllDay: false,
	startDate: new Date("2023-01-01T18:00:00.000Z"),
	endDate: new Date("2023-01-01T22:00:00.000Z"),
	location: { title: "My place" },
	url: "https://optional-video-call.com",
})
```

## Examples

### File System

```typescript
import { generateIcal } from "generate-ical"
import fs from "fs"

const fileContent = generateIcal({
	/* ... */
})
fs.writeFileSync("./Event.ics", fileContent)
```

### Koa

```typescript
import { generateIcal } from "generate-ical"

context.response.set("Content-Type", "text/calendar")
context.response.set("Content-Disposition", `attachment; filename="Event.ics"`)
context.body = generateIcal({
	/* ... */
})
```

### Redirect to Calendar

```typescript
import { generateGoogleUrl, generateOffice365Url } from "generate-ical"

const event = {
	/* ... */
}

router.get("/add-to-google", (req, res) => {
	res.redirect(generateGoogleUrl(event))
})

router.get("/add-to-office365", (req, res) => {
	res.redirect(generateOffice365Url(event))
})
```

---
_Source: https://npm.io/package/generate-ical · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
