next-forge Documentation

Production-grade Turborepo template for Next.js apps.

7,062 stars TypeScript TypeScript 1 file ยท ~3,388 tokens #betterstack#boilerplate#clerk#dark-mode#feature-flags#neon#nextjs#posthog
RAW Doc

File: README.md

โ–ฒ / next-forge

Production-grade Turborepo template for Next.js apps.

Overview

next-forge is a production-grade Turborepo template for Next.js apps. It's designed to be a comprehensive starting point for building SaaS applications, providing a solid, opinionated foundation with minimal configuration required.

Built on a decade of experience building web applications, next-forge balances speed and quality to help you ship thoroughly-built products faster.

Philosophy

next-forge is built around five core principles:

  • Fast โ€” Quick to build, run, deploy, and iterate on
  • Cheap โ€” Free to start with services that scale with you
  • Opinionated โ€” Integrated tooling designed to work together
  • Modern โ€” Latest stable features with healthy community support
  • Safe โ€” End-to-end type safety and robust security posture

Demo

Experience next-forge in action:

  • Web โ€” Marketing website
  • App โ€” Main application
  • Storybook โ€” Component library
  • API โ€” API health check

Features

next-forge comes with batteries included:

Apps

  • Web โ€” Marketing site built with Tailwind CSS and TWBlocks
  • App โ€” Main application with authentication and database integration
  • API โ€” RESTful API with health checks and monitoring
  • Docs โ€” Documentation site powered by Mintlify
  • Email โ€” Email templates with React Email
  • Storybook โ€” Component development environment

Packages

  • Authentication โ€” Powered by Clerk
  • Database โ€” Type-safe ORM with migrations
  • Design System โ€” Comprehensive component library with dark mode
  • Payments โ€” Subscription management via Stripe
  • Email โ€” Transactional emails via Resend
  • Analytics โ€” Web (Google Analytics) and product (Posthog)
  • Observability โ€” Error tracking (Sentry), logging, and uptime monitoring (BetterStack)
  • Security โ€” Application security (Arcjet), rate limiting, and secure headers
  • CMS โ€” Type-safe content management for blogs and documentation
  • SEO โ€” Metadata management, sitemaps, and JSON-LD
  • AI โ€” AI integration utilities
  • Webhooks โ€” Inbound and outbound webhook handling
  • Collaboration โ€” Real-time features with avatars and live cursors
  • Feature Flags โ€” Feature flag management
  • Cron โ€” Scheduled job management
  • Storage โ€” File upload and management
  • Internationalization โ€” Multi-language support
  • Notifications โ€” In-app notification system

Getting Started

Prerequisites

  • Node.js 20+
  • Bun (or npm/yarn/pnpm)
  • Stripe CLI for local webhook testing

Installation

Create a new next-forge project:

sh
npx next-forge@latest init

Setup

  1. Configure your environment variables
  2. Set up required service accounts (Clerk, Stripe, Resend, etc.)
  3. Run the development server

For detailed setup instructions, read the documentation.

Structure

next-forge uses a monorepo structure managed by Turborepo:

text
next-forge/
โ”œโ”€โ”€ apps/           # Deployable applications
โ”‚   โ”œโ”€โ”€ web/        # Marketing website (port 3001)
โ”‚   โ”œโ”€โ”€ app/        # Main application (port 3000)
โ”‚   โ”œโ”€โ”€ api/        # API server
โ”‚   โ”œโ”€โ”€ docs/       # Documentation
โ”‚   โ”œโ”€โ”€ email/      # Email templates
โ”‚   โ””โ”€โ”€ storybook/  # Component library
โ””โ”€โ”€ packages/       # Shared packages
    โ”œโ”€โ”€ design-system/
    โ”œโ”€โ”€ database/
    โ”œโ”€โ”€ auth/
    โ””โ”€โ”€ ...

Each app is self-contained and independently deployable. Packages are shared across apps for consistency and maintainability.

Documentation

Full documentation is available at next-forge.com/docs, including:

  • Detailed setup guides
  • Package documentation
  • Migration guides for swapping providers
  • Deployment instructions
  • Examples and recipes

Contributing

We welcome contributions! See the contributing guide for details.

Contributors

Made with contrib.rocks.

License

MIT


File: apps/storybook/README.md

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

bash
bun dev
# or
npm run dev
# or
yarn dev
# or
pnpm dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying pages/index.tsx. The page auto-updates as you edit the file.

API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.ts.

The pages/api directory is mapped to /api/*. Files in this directory are treated as API routes instead of React pages.

This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.


File: apps/docs/api-reference/introduction.mdx


title: 'Introduction'

If you're not looking to build API reference documentation, you can delete this section by removing the api-reference folder.

Welcome

There are two ways to build API documentation: OpenAPI and MDX components. For the starter kit, we are using the following OpenAPI specification.

<Card
title="Plant Store Endpoints"
icon="leaf"
href="https://github.com/mintlify/starter/blob/main/api-reference/openapi.json"

View the OpenAPI specification file

Authentication

All API endpoints are authenticated using Bearer tokens and picked up from the specification file.

json
"security": [
  {
    "bearerAuth": []
  }
]

File: apps/docs/essentials/code.mdx


title: 'Code Blocks' icon: 'code'

Basic

Inline Code

To denote a word or phrase as code, enclose it in backticks (`).

text
To denote a `word` or `phrase` as code, enclose it in backticks (`).

Code Block

Use fenced code blocks by enclosing code in three backticks and follow the leading ticks with the programming language of your snippet to get syntax highlighting. Optionally, you can also write the name of your code after the programming language.

java helloworld.java
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
md
```java HelloWorld.java
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
```

File: apps/docs/essentials/images.mdx


title: 'Images and Embeds' icon: 'image'

Image

Using Markdown

The markdown syntax lets you add images using the following code

md

Note that the image file size must be less than 5MB. Otherwise, we recommend hosting on a service like Cloudinary or S3. You can then use that URL and embed.

Using Embeds

To get more customizability with images, you can also use embeds to add images

html

Embeds and HTML elements

Mintlify supports HTML tags in Markdown. This is helpful if you prefer HTML tags to Markdown syntax, and lets you create documentation with infinite flexibility.

iFrames

Loads another HTML page within the document. Most commonly used for embedding videos.

html

File: apps/docs/essentials/markdown.mdx


title: 'Markdown Syntax' icon: 'text-size'

Titles

Best used for section headers.

md
## Titles

Subtitles

Best use to subsection headers.

md
### Subtitles

Each title and subtitle creates an anchor and also shows up on the table of contents on the right.

Text Formatting

We support most markdown formatting. Simply add **, _, or ~ around text to format it.

Style How to write it Result
Bold **bold** bold
Italic _italic_ italic
Strikethrough ~strikethrough~ strikethrough

You can combine these. For example, write **_bold and italic_** to get bold and italic text.

You need to use HTML to write superscript and subscript text. That is, add <sup> or <sub> around your text.

Text Size How to write it Result
Superscript <sup>superscript</sup> superscript
Subscript <sub>subscript</sub> subscript

Linking to Pages

You can add a link by wrapping text in [](). You would write [link to google](https://google.com) to link to google.

Links to pages in your docs need to be root-relative. Basically, you should include the entire folder path. For example, [link to text](/writing-content/text) links to the page "Text" in our components section.

Relative links like [link to text](../text) will open slower because we cannot optimize them as easily.

Blockquotes

Singleline

To create a blockquote, add a > in front of a paragraph.

Dorothy followed her through many of the beautiful rooms in her castle.

md
> Dorothy followed her through many of the beautiful rooms in her castle.

Multiline

Dorothy followed her through many of the beautiful rooms in her castle.

The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.

md
> Dorothy followed her through many of the beautiful rooms in her castle.
>
> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.

LaTeX

Mintlify supports LaTeX through the Latex component.

8 x (vk x H1 - H2) = (0,1)

md
<Latex>8 x (vk x H1 - H2) = (0,1)</Latex>

File: apps/docs/essentials/navigation.mdx


title: 'Navigation' icon: 'map'

The navigation menu is the list of links on every website.

You will likely update mint.json every time you add a new page. Pages do not show up automatically.

Our navigation syntax is recursive which means you can make nested navigation groups. You don't need to include .mdx in page names.

json regular navigation
"navigation": [
    {
        "group": "Getting Started",
        "pages": ["quickstart"]
    }
]
json nested navigation
"navigation": [
    {
        "group": "Getting Started",
        "pages": [
            "quickstart",
            {
                "group": "Nested Reference Pages",
                "pages": ["nested-reference-page"]
            }
        ]
    }
]

Folders

Simply put your MDX files in folders and update the paths in mint.json.

For example, to have a page at https://yoursite.com/your-folder/your-page you would make a folder called your-folder containing an MDX file called your-page.mdx.

You cannot use api for the name of a folder unless you nest it inside another folder. Mintlify uses Next.js which reserves the top-level api folder for internal server calls. A folder name such as api-reference would be accepted.

json navigation with folder
"navigation": [
    {
        "group": "Group Name",
        "pages": ["your-folder/your-page"]
    }
]

Hidden Pages

MDX files not included in mint.json will not show up in the sidebar but are accessible through the search bar and by linking directly to them.