Quick Start Guide
Get the site running on your local machine in just a few steps. This guide assumes you have Node.js 18+ installed.Prerequisites: Node.js 18+, pnpm (or npm), and a Notion account
Installation Steps
Install Dependencies
This project uses pnpm as the package manager. Install it if you don’t have it:Then install project dependencies:
The project uses
"type": "module" in package.json, enabling ES module syntax throughout the codebase.Set Up Environment Variables
Create a Add your Notion credentials (see Environment Setup for details):
.env file in the project root. You’ll need Notion API credentials:Start Development Server
Run the development server:This command does two things:
- Runs the pre-build script (
jiti scripts/index.ts) to sync Notion content - Starts the Astro development server on
http://localhost:4321
The pre-build script is defined in package.json:
Available Scripts
The project includes several npm scripts for different workflows:Understanding the Pre-Build Hook
Bothpnpm dev and pnpm build automatically run the content sync script before starting. Here’s what happens:
- Connects to your Notion workspace using
NOTION_TOKEN - Queries blog and project databases
- Downloads content that has changed since last sync
- Converts Notion blocks to MDX format
- Writes files to
src/content/blog/andsrc/content/projects/
The sync is incremental - it only updates files where
lastEditedTime in Notion is newer than the local file.Project Structure Overview
Here’s what you’ll find in the codebase:Verify Installation
To ensure everything is working correctly:Check Notion Sync
After running You should see
pnpm dev, verify MDX files were created:.mdx files with Notion page IDs as filenames.Common Issues
Build fails with 'Cannot find module dotenv'
Build fails with 'Cannot find module dotenv'
Make sure you installed dependencies with
pnpm install. The project uses dotenv for environment variable management.No MDX files in src/content/
No MDX files in src/content/
This means the Notion sync didn’t run or failed. Check:
.envfile exists with validNOTION_TOKEN- Database IDs are correct
- Your Notion integration has access to the databases
- Run
pnpm devand watch for error messages
Port 4321 already in use
Port 4321 already in use
Either kill the process using port 4321, or start Astro on a different port:
TypeScript errors in IDE
TypeScript errors in IDE
Make sure your IDE is using the workspace TypeScript version. In VS Code:
- Open any
.tsfile - Press
Cmd+Shift+P(Mac) orCtrl+Shift+P(Windows) - Select “TypeScript: Select TypeScript Version”
- Choose “Use Workspace Version”
Development Tips
Fast Refresh
Astro’s dev server supports instant HMR (Hot Module Replacement). Changes to components appear immediately without full page reload.
Type Safety
The project uses TypeScript throughout. Content schemas in
src/content.config.ts validate all Notion data at build time.Incremental Sync
Only changed Notion pages are re-downloaded. Delete
src/content/ to force a full re-sync.Notion Test
Create a test page in your Notion blog database and mark it public. Run
pnpm dev to see it sync.Next Steps
Now that you have the site running:Environment Setup
Learn how to configure Notion databases and environment variables in detail
Content Schema
Understand the frontmatter schema and how Notion properties map to MDX
Customization
Customize styles, add new pages, and modify the Notion sync logic
Deployment
Deploy to Vercel or your preferred hosting platform
Ready to customize? Check out
src/pages/index.astro to see how pages fetch and render Notion content.