Deploy your own Notion-powered website in minutes with Next.js and Vercel.
Deploy your own Notion-powered website in minutes with Next.js and Vercel.
We use [next/image](https://nextjs.org/docs/api-reference/next/image) to serve images efficiently, with preview images optionally generated via [lqip-modern](https://github.com/transitive-bullshit/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](https://redis.io) 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: ```bash REDIS_HOST='TODO' REDIS_PASSWORD='TODO' ``` If you're not sure which Redis provider to use, we recommend [Redis Labs](https://redis.com), 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](./styles/notion.css). They mainly target global CSS classes exported by react-notion-x [styles.css](https://github.com/NotionX/react-notion-x/blob/master/packages/react-notion-x/src/styles.css). Every notion block gets its own unique classname, so you can target individual blocks like this: ```css .notion-block-260baa77f1e1428b97fb14ac99c7c385 { display: none; } ``` ## Dark Mode
Dark mode is fully supported and can be toggled via the sun / moon icon in the footer. ## Automatic Social Images
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](https://vercel.com/docs/concepts/functions/edge-functions/og-image-generation). You can tweak the default React template for social images by editing [route.tsx](./app/api/social-image/route.tsx). You can view an example social image live in production [here](https://transitivebullsh.it/api/social-image?id=dfc7f709-ae3e-42c6-9292-f6543d5586f0). ## Automatic Table of Contents
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](https://github.com/NotionX/react-notion-x/blob/master/packages/notion-utils/src/get-page-table-of-contents.ts) for the underlying logic). ## Responsive
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](https://usefathom.com/ref/42TFOZ) 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](https://posthog.com/) 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](https://vercel.com/docs/concepts/projects/environment-variables). If you want to test your redis builds with GitHub Actions, then you'll need to edit the [default build action](./.github/workflows/build.yml) to add `REDIS_HOST` and `REDIS_PASSWORD`. Here is an [example from my personal branch](https://github.com/transitive-bullshit/nextjs-notion-starter-kit/blob/transitive-bullshit/.github/workflows/build.yml#L17-L21). You'll also need to add these environment variables to your GitHub repo as [repository secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets). ## Contributing See the [contribution guide](contributing.md) and join our amazing list of [contributors](https://github.com/transitive-bullshit/nextjs-notion-starter-kit/graphs/contributors)! ## License MIT © [Travis Fischer](https://transitivebullsh.it) Support my open source work by following me on twitter
No open issues yet, or sync has not completed.