• Stars
    star
    4,211
  • Rank 10,267 (Top 0.3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Deploy your own Notion-powered website in minutes with Next.js and Vercel.

Example article page

Next.js Notion Starter Kit

The perfect starter kit for building websites with Next.js and Notion.

Build Status Prettier Code Formatting

Intro

This repo is what I use to power my personal blog and portfolio site transitivebullsh.it.

It uses Notion as a CMS, react-notion-x, Next.js, and Vercel.

Features

  • Setup only takes a few minutes (single config file) 💪
  • Robust support for Notion content via react-notion-x
  • Built using Next.js, TS, and React
  • Excellent page speeds
  • Smooth image previews
  • Automatic social images
  • Automatic pretty URLs
  • Automatic table of contents
  • Full support for dark mode
  • Quick search via CMD+K / CMD+P
  • Responsive for different devices
  • Optimized for Next.js and Vercel

Demos

  • Default demo - Deployed from the main branch
  • My site - Deployed from the transitive-bullshit branch

Setup

All config is defined in site.config.ts.

This project requires a recent version of Node.js (we recommend >= 16).

  1. Fork / clone this repo
  2. Change a few values in site.config.ts
  3. npm install
  4. npm run dev to test locally
  5. npm run deploy to deploy to vercel 💪

I tried to make configuration as easy as possible — All you really need to do to get started is edit rootNotionPageId.

We recommend duplicating the default page as a starting point, but you can use any public notion page you want.

Make sure your root Notion page is public and then copy the link to your clipboard. Extract the last part of the URL that looks like 7875426197cf461698809def95960ebf, which is your page's Notion ID.

In order to find your Notion workspace ID (optional), just load any of your site's pages into your browser and open up the developer console. There will be a global variable that you can access called block which is the Notion data for the current page. If you enter block.space_id, it will print out your page's workspace ID.

I recommend setting up a collection on your home page that contains all of your articles / projects / content. There are no structural constraints on your Notion workspace, however, so feel free to add content as you normally would in Notion.

URL Paths

The app defaults to slightly different URL paths in dev vs prod (though pasting any dev pathname into prod will work and vice-versa).

In development, it will use /nextjs-notion-blog-d1b5dcf8b9ff425b8aef5ce6f0730202 which is a slugified version of the page's title suffixed with its Notion ID. I've found that it's really useful to always have the Notion Page ID front and center during local development.

In production, it will use /nextjs-notion-blog which is a bit nicer as it gets rid of the extra ID clutter.

The mapping of Notion ID to slugified page titles is done automatically as part of the build process. Just keep in mind that if you plan on changing page titles over time, you probably want to make sure old links will still work, and we don't currently provide a solution for detecting old links aside from Next.js's built-in support for redirects.

See mapPageUrl and getCanonicalPageId for more details.

You can override the default slug generation on a per-page basis by adding a Slug text property to your database. Any page which has a Slug property will use that as its slug.

NOTE: if you have multiple pages in your workspace with the same slugified name, the app will throw an error letting you know that there are duplicate URL pathnames.

Preview Images

Example preview image

We use next/image to serve images efficiently, with preview images optionally generated via lqip-modern. This gives us extremely optimized image support for sexy smooth images.

Preview images are enabled by default, but they can be slow to generate, so if you want to disable them, set isPreviewImageSupportEnabled to false in site.config.ts.

Redis

If you want to cache generated preview images to speed up subsequent builds, you'll need to first set up an external Redis data store. To enable redis caching, set isRedisEnabled to true in site.config.ts and then set REDIS_HOST and REDIS_PASSWORD environment variables to point to your redis instance.

You can do this locally by adding a .env file:

REDIS_HOST='TODO'
REDIS_PASSWORD='TODO'

If you're not sure which Redis provider to use, we recommend Redis Labs, which provides a free plan.

Note that preview images and redis caching are both optional features. If you’d rather not deal with them, just disable them in your site config.

Styles

All CSS styles that customize Notion content are located in styles/notion.css. They mainly target global CSS classes exported by react-notion-x styles.css.

Every notion block gets its own unique classname, so you can target individual blocks like this:

.notion-block-260baa77f1e1428b97fb14ac99c7c385 {
  display: none;
}

Dark Mode

Light Mode         Dark Mode

Dark mode is fully supported and can be toggled via the sun / moon icon in the footer.

Automatic Social Images

Example social image

All Open Graph and social meta tags are generated from your Notion content, which makes social sharing look professional by default.

Social images are generated automatically using Vercel OG Image Generation. You can tweak the default React template for social images by editing api/social-images.tsx.

You can view an example social image live in production here.

Automatic Table of Contents

Smooth ToC Scrollspy

By default, every article page will have a table of contents displayed as an aside on desktop. It uses scrollspy logic to automatically update the current section as the user scrolls through your document, and makes it really easy to jump between different sections.

If a page has less than minTableOfContentsItems (default 3), the table of contents will be hidden. It is also hidden on the index page and if the browser window is too small.

This table of contents uses the same logic that Notion uses for its built-in Table of Contents block (see getPageTableOfContents for the underlying logic).

Responsive

Mobile article page

All pages are designed to be responsive across common device sizes.

Analytics

Analytics are an optional feature that are easy to enable if you want.

Fathom Analytics

Fathom provides a lightweight alternative to Google Analytics.

To enable, just add a NEXT_PUBLIC_FATHOM_ID environment variable, which will only be used in production.

PostHog Analytics

PostHog provides a lightweight, open source alternative to Google Analytics.

To enable, just add a NEXT_PUBLIC_POSTHOG_ID environment variable, which will only be used in production.

Environment Variables

If you're using Redis, analytics, or any other feature which requires environment variables, then you'll need to add them to your Vercel project.

If you want to test your redis builds with GitHub Actions, then you'll need to edit the default build action to add REDIS_HOST and REDIS_PASSWORD. Here is an example from my personal branch. You'll also need to add these environment variables to your GitHub repo as repository secrets.

Contributing

See the contribution guide and join our amazing list of contributors!

License

MIT © Travis Fischer

Support my open source work by following me on twitter twitter

More Repositories

1

chatgpt-api

Node.js client for the official ChatGPT API. 🔥
TypeScript
12,733
star
2

create-react-library

CLI for creating reusable react libraries.
JavaScript
4,783
star
3

awesome-puppeteer

A curated list of awesome puppeteer resources.
2,073
star
4

react-particle-effect-button

Bursting particle effect buttons for React 🎉
JavaScript
1,463
star
5

awesome-ffmpeg

👻 A curated list of awesome FFmpeg resources.
847
star
6

bing-chat

Node.js client for Bing's new AI-powered search. It's like ChatGPT on steroids 🔥
TypeScript
745
star
7

ffmpeg-concat

Concats a list of videos together using ffmpeg with sexy OpenGL transitions.
JavaScript
721
star
8

chatgpt-twitter-bot

Twitter bot powered by OpenAI's ChatGPT API. It's aliveeeee 🤖
TypeScript
629
star
9

functional-typescript

TypeScript standard for rock solid serverless functions.
TypeScript
628
star
10

chatgpt-plugin-ts

Everything you need to start building ChatGPT Plugins in JS/TS 🔥
TypeScript
546
star
11

ffmpeg-gl-transition

FFmpeg filter for applying GLSL transitions between video streams.
C
525
star
12

OpenOpenAI

Self-hosted version of OpenAI’s new stateful Assistants API
TypeScript
509
star
13

react-static-tweets

Extremely fast static renderer for tweets.
TypeScript
506
star
14

yt-semantic-search

OpenAI-powered semantic search for any YouTube playlist – featuring the All-In Podcast. 💪
TypeScript
423
star
15

twitter-search

Instantly search across your entire Twitter history with a beautiful UI powered by Algolia.
TypeScript
347
star
16

check-links

Robustly checks an array of URLs for liveness. Extremely fast âš¡
JavaScript
324
star
17

react-modern-library-boilerplate

Boilerplate for publishing modern React modules with Rollup
JavaScript
324
star
18

puppeteer-lottie

Renders Lottie animations via Puppeteer to image, GIF, or MP4.
JavaScript
309
star
19

snapchat

NodeJS client for the unofficial Snapchat API
JavaScript
265
star
20

lqip-modern

Modern approach to Low Quality Image Placeholders (LQIP) using webp and sharp.
JavaScript
221
star
21

sms-number-verifier

Allows you to spoof SMS number verification.
JavaScript
173
star
22

puppeteer-email

Email automation driven by headless chrome.
JavaScript
149
star
23

ffmpeg-generate-video-preview

Generates an attractive image strip or GIF preview from a video.
JavaScript
138
star
24

random

The most random module on npm
TypeScript
128
star
25

scikit-learn-ts

Powerful machine learning library for Node.js – uses Python's scikit-learn under the hood.
TypeScript
125
star
26

react-background-slideshow

Sexy tiled background slideshow for React 🔥
JavaScript
111
star
27

captcha-solver

Library and CLI for automating captcha verification across multiple providers.
JavaScript
107
star
28

chatgpt-well-known-plugin-finder

Checks Alexa's top 1M websites for the presence of OpenAI's new .well-known/ai-plugin.json files
TypeScript
106
star
29

puppeteer-lottie-cli

CLI for rendering Lottie animations via Puppeteer to image, GIF, or MP4.
JavaScript
106
star
30

react-suspense-polyfill

Polyfill for the React Suspense API 😮
JavaScript
100
star
31

puppeteer-instagram

Instagram automation driven by headless chrome.
JavaScript
100
star
32

chatgpt-hackers

Join thousands of other developers, researchers, and AI enthusiasts who are building at the cutting edge of AI ✨
TypeScript
97
star
33

react-starfield-animation

✨ Canvas-based starfield animation for React.
JavaScript
96
star
34

react-mp3-recorder

Microphone recorder for React that captures mp3 audio 🎵
JavaScript
84
star
35

react-particle-animation

✨Canvas-based particle animation for React.
JavaScript
81
star
36

react-fluid-gallery

Fluid media gallery for React powered by WebGL.
JavaScript
75
star
37

primitive

Reproduce images from geometric primitives.
JavaScript
74
star
38

npm-es-modules

Breakdown of 7 different ways to use ES modules with npm today.
JavaScript
69
star
39

react-fluid-animation

Fluid media animation for React powered by WebGL.
JavaScript
68
star
40

react-before-after-slider

A sexy image comparison slider for React.
JavaScript
62
star
41

ffmpeg-extract-frames

Extracts frames from a video using ffmpeg.
JavaScript
60
star
42

puppeteer-render-text

Robust text renderer using headless chrome.
JavaScript
59
star
43

text-summarization

Automagically generates summaries from html or text.
JavaScript
54
star
44

kwote

Create beautiful quotes that capture your attention.
TypeScript
49
star
45

next-movie

Pick your next movie using Next.js 13
TypeScript
45
star
46

bens-bites-ai-search

AI search for all the best resources in AI – powered by Ben's Bites 💯
TypeScript
45
star
47

ffmpeg-cli-flags

A comprehensive list of all ffmpeg commandline flags.
44
star
48

twitter-feed-algorithm

TypeScript code exploring what an open source version of Twitter's algorithmic feed might look like.
TypeScript
42
star
49

scrape-github-trending

Tutorial for web scraping / crawling with Node.js.
JavaScript
42
star
50

clubhouse

Clubhouse API client and social graph crawler for TypeScript.
TypeScript
41
star
51

populate-movies

Populates a high quality database of movies from TMDB, IMDB, and Rotten Tomatoes.
TypeScript
36
star
52

react-fake-tweet

React renderer for tweets.
JavaScript
33
star
53

ip-set

Efficient mutable set data structure optimized for use with IPv4 and IPv6 addresses. The primary use case is for working with potentially large IP blacklists.
JavaScript
33
star
54

cf-image-proxy

Image proxy and CDN for CF workers. Simple, extremely fast, and free.
JavaScript
31
star
55

node-compat-require

Easily allow your Node program to run in a target node version range to maximize compatibility.
JavaScript
22
star
56

avp

Audio Visual Playground, or Alien vs Predator? You decide...
TypeScript
22
star
57

p-cache

Decorator to memoize the results of async functions via lru-cache.
JavaScript
22
star
58

parse-otp-message

Parses OTP messages for a verification code and service provider.
JavaScript
21
star
59

spotify-to-twitter

Example of how to create your own automated Twitter account that tweets tracks from a Spotify playlist.
JavaScript
21
star
60

gif-extract-frames

Extracts frames from a GIF including inter-frame coalescing.
JavaScript
21
star
61

puppeteer-instaquote

Use Puppeteer to create snazzy Instagram-like quote images and memes
JavaScript
20
star
62

async-await-parallel

Node.js module with simple concurrency control for awaiting an array of async results
JavaScript
20
star
63

internet-diet

Chrome extension to remove unhealthy foods from the web.
HTML
18
star
64

react-block-image

React replacement for img with more control + fallback support.
JavaScript
18
star
65

react-docgen-props-table

Beautiful Props Table for React Docgen.
JavaScript
17
star
66

lexica-api

API wrapper around Lexica.art for searching Stable Diffusion images.
TypeScript
16
star
67

puppeteer-github

GitHub automation driven by headless chrome.
JavaScript
16
star
68

google-waitlist

Sign up for Google's latest AI-powered waitlist today!
TypeScript
16
star
69

ffmpeg-extract-frame

Extracts a single frame from a video.
JavaScript
15
star
70

compare-tokenizers

A test suite comparing Node.js BPE tokenizers for use with AI models.
TypeScript
15
star
71

ffmpeg-extract-audio

Extracts an audio stream from a media file.
JavaScript
14
star
72

replicate-api

Node.js wrapper around Replicate's ML API (including dreambooth + stable diffusion).
TypeScript
14
star
73

Gravity-spritekit

iOS n-body simulation visualized with metaballs. Physics and graphics provided by SpriteKit.
Swift
14
star
74

getsmscode

API client for getsmscode.com
JavaScript
13
star
75

nala

In loving memory of Nala Das Kitten; 2010 - 2023. 💕
TypeScript
13
star
76

ffmpeg-probe

Wrapper around ffprobe for getting info about media files.
JavaScript
13
star
77

apple-april-fools-2023

Fake Apple AI product launch for April Fool's Day 2023.
TypeScript
13
star
78

ffmpeg-on-progress

Utility for robustly reporting progress with fluent-ffmpeg.
JavaScript
13
star
79

dissolve-generator

Cool 2D dissolve effect generator
JavaScript
13
star
80

abstract-object-storage

Collection of useful utilities for working with Google Cloud Storage.
JavaScript
12
star
81

Milton

C++ Rendering Framework w/ MLT, bidi path tracing, etc. and OpenGL Previews (undergrad thesis project from Brown '09)
12
star
82

koa2-mongoose-crud

Koa 2 CRUD middleware for Mongoose models.
JavaScript
11
star
83

get-mp3-duration

Computes the duration of an mp3 buffer in node or browser.
JavaScript
11
star
84

github-scraper

Misc scripts for scraping GitHub.
TypeScript
9
star
85

create-vue-library

JavaScript
9
star
86

warm-social-images

Simple CLI to warm the cache of social images in all pages from a sitemap.
JavaScript
9
star
87

primitive-cli

CLI to reproduce images from geometric primitives.
JavaScript
9
star
88

puppeteer-render-text-cli

CLI for rendering text with headless chrome.
JavaScript
9
star
89

github-is-starred-cli

CLI for checking if a user has starred a particular GitHub repo.
JavaScript
9
star
90

open-source

Keeping track of my various open source projects.
8
star
91

id-shortener

Efficient id / url shortener for NodeJS backed by pluggable storage defaulting to redis.
JavaScript
8
star
92

update-markdown-jsdoc

Updates a markdown document section with jsdoc documentation.
JavaScript
7
star
93

commit-emoji

Performs a git commit with a random emoji message. 😂 🤙 🚀
JavaScript
7
star
94

github-is-starred

Checks if a user has starred a particular GitHub repo.
JavaScript
7
star
95

puppeteer-github-cli

CLI for GitHub automation driven by headless chrome.
JavaScript
7
star
96

wahlburger

Get dem burgers
JavaScript
7
star
97

phash-im

Perceptual image hashing provided by imagemagick.
JavaScript
6
star
98

phash-gif

Perceptual GIF hashing for easily finding near-duplicate GIFs.
JavaScript
6
star
99

is-acronym

Determines whether a given string is a common English acronym.
JavaScript
5
star
100

react-springy-scroll

React utility that adds a physical springiness to elements on scroll.
JavaScript
5
star