Documentation
Everything you need to know about using Chronalog in your Next.js project.
Getting Started
Installation
Install Chronalog in your Next.js project using pnpm:
pnpm add chronalogInitialisation
Run the init command to scaffold the necessary files and directories:
pnpm chronalog initThis will create:
- Admin page at
/app/(cms)/chronalog/page.tsx - Settings page at
/app/(cms)/chronalog/settings/page.tsx - API routes for saving, listing, and fetching changelog entries
- GitHub OAuth authentication routes
- Configuration file at
changelog.config.ts - Changelog directory at
chronalog/changelog
GitHub OAuth Setup
Chronalog uses GitHub OAuth for authentication. Set up your GitHub OAuth app:
- Create a GitHub OAuth App at https://github.com/settings/developers
- Set the Authorization callback URL to:
http://localhost:3000/api/changelog/auth/callback - Add the following to your
.env.localfile:
CHRONALOG_GITHUB_ID=your_client_idCHRONALOG_GITHUB_SECRET=your_client_secretCHRONALOG_TOKEN_SECRET=your_secret_keyNote: CHRONALOG_TOKEN_SECRET is optional for local development but recommended for production.
Requirements
- Next.js 14.0.0 or higher
- React 18.0.0 or higher
- Tailwind CSS 4.0.0 or higher
- Git (for auto-commit functionality)
Deployment
Deploying to Vercel
When deploying to Vercel or other serverless platforms, Chronalog uses the GitHub API to fetch changelog entries since the filesystem is read-only. To ensure your public changelog page works correctly, you need to set up a GitHub access token.
Creating a GitHub Personal Access Token
Create a GitHub personal access token for your deployment:
- Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click "Generate new token" → "Generate new token (classic)"
- Give it a descriptive name (e.g., "Chronalog Vercel Deployment")
- Select the appropriate scopes:
repo- Full control of private repositories (if your repo is private)public_repo- Access public repositories (if your repo is public)
- Click "Generate token" and copy it immediately (you won't be able to see it again)
Adding the Token to Vercel
Add the token as an environment variable in your Vercel project:
- Go to your Vercel project dashboard
- Navigate to Settings → Environment Variables
- Add a new environment variable:
- Name:
CHRONALOG_GITHUB_TOKEN - Value: Your GitHub personal access token
- Environment: Select all (Production, Preview, Development)
- Name:
- Click "Save"
- Redeploy your application for the changes to take effect
Environment Variable:
CHRONALOG_GITHUB_TOKEN=your_github_tokenHow It Works
Chronalog uses the access token in the following priority order:
- User session token - If a user is logged in via GitHub OAuth, their session token is used (highest priority)
- Environment variable token - The
CHRONALOG_GITHUB_TOKENis used as a fallback for public pages - No token - For public repositories, the GitHub REST API is used without authentication (may be subject to rate limits)
Note: For private repositories, an access token is required. The environment variable token ensures your public changelog page works without requiring users to log in.
Repository Configuration (Optional)
If your Vercel deployment is not connected to Git, or if Git commands are not available in your serverless environment, you can manually specify your repository details using these environment variables:
CHRONALOG_REPO_OWNER=your_github_usernameCHRONALOG_REPO_SLUG=your_repo_nameCHRONALOG_REPO_BRANCH=mainWhen to use these: These are only needed if Chronalog cannot automatically detect your repository from Git commands. Vercel automatically provides VERCEL_GIT_REPO_OWNER and VERCEL_GIT_REPO_SLUG when your project is connected to Git, so you typically don't need to set these manually.
Complete Environment Variables List
Here's a complete list of all environment variables you may need in Vercel:
CHRONALOG_GITHUB_ID=your_client_idCHRONALOG_GITHUB_SECRET=your_client_secretCHRONALOG_GITHUB_TOKEN=your_github_tokenCHRONALOG_TOKEN_SECRET=your_secret_keyCHRONALOG_REPO_OWNER=your_github_usernameCHRONALOG_REPO_SLUG=your_repo_nameCHRONALOG_REPO_BRANCH=mainRequired for OAuth: CHRONALOG_GITHUB_ID and CHRONALOG_GITHUB_SECRET are needed for GitHub OAuth authentication in the admin interface.
Required for deployment: CHRONALOG_GITHUB_TOKEN ensures your public changelog page works without requiring user authentication.
Optional: CHRONALOG_TOKEN_SECRET is recommended for production to secure session tokens. CHRONALOG_REPO_OWNER, CHRONALOG_REPO_SLUG, and CHRONALOG_REPO_BRANCH are only needed if Git commands are unavailable.
Changelog Entry Schema
Changelog entries are stored as MDX files with YAML frontmatter. Here's the complete schema:
Required Fields
title(string) - The title of the changelog entrydate(string) - ISO datetime format: YYYY-MM-DDTHH:mm:ss.sssZbody(string) - The main content/body of the changelog entry (MDX/HTML)
Optional Fields
version(string) - Version number (e.g., "1.0.0")tags(string[]) - Array of tags for categorisationfeatures(string[]) - Array of feature descriptionsbugfixes(string[]) - Array of bug fix descriptions
Example Entry
--- title: Version 1.0.0 Release date: 2024-01-15T14:30:00.000Z version: 1.0.0 tags: - "release" - "feature" features: - "Added user authentication system" - "Implemented dark mode" bugfixes: - "Fixed login redirect issue" --- This release includes major new features and important bug fixes. ## Highlights - Complete authentication overhaul - Improved performance across the board - Better user experience
API Usage
Saving Entries
Save changelog entries via the API endpoint:
POST /api/changelog/save
Content-Type: application/json
{
"title": "New Feature Release",
"version": "1.0.0",
"date": "2024-01-15",
"tags": ["feature", "release"],
"features": ["Added new authentication"],
"bugfixes": ["Fixed login issue"],
"body": "This is the main content..."
}Reading Entries
Use the Chronalog utilities to read and list entries:
import {
listChangelogEntries,
readChangelogEntry,
filterChangelogEntriesByTags,
getAllTags
} from "chronalog";
// List all entries
const entries = listChangelogEntries();
// Read a specific entry
const entry = readChangelogEntry("my-entry-slug");
// Filter by tags
const featureEntries = filterChangelogEntriesByTags(
entries,
["feature"]
);
// Get all available tags
const tags = getAllTags(entries);