Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Next.js blog example with Auth0-protected comments stored in Upstash Serverless Redis.
Blog with Comment is an official Next.js starter template from the Vercel examples repository that adds Auth0-protected comments to the base Next.js blog, storing each comment in Upstash Serverless Redis.
Blog with Comment is a Next.js application you generate with npx create-next-app --example blog-with-comment. It extends the standard Next.js blog example with a comment system: visitors must sign in through Auth0 to post a comment, each user can delete only their own comment, and an admin (defined by an environment variable) can delete any comment. All comments are persisted in Upstash, a Serverless Redis database, accessed through the REDIS_URL environment variable. The template is part of the official vercel/next.js GitHub repository, which currently has over 141,000 stars, and it is designed to be deployed directly to Vercel.
NEXT_PUBLIC_AUTH0_ADMIN_EMAIL can delete every comment on the blog.REDIS_URL environment variable..env.local, using NEXT_PUBLIC_AUTH0_DOMAIN, NEXT_PUBLIC_AUTH0_CLIENT_ID, NEXT_PUBLIC_AUTH0_ADMIN_EMAIL, and REDIS_URL.npx create-next-app --example blog-with-comment, giving you a working blog with comments in one command.vercel/next.js repository, so it stays aligned with Next.js updates and is maintained by the Vercel team.Next.js developers who want a reference implementation for adding authenticated comments to a blog without building an auth system and a database from scratch. Bloggers who already use the Next.js blog example and need a comment feature that requires login and supports admin moderation. Teams learning how to integrate Auth0 with Next.js, because the README gives exact setting values for callback URLs, logout URLs, and web origins. Vercel users who want a serverless-deployable blog with comments, since the project can be imported directly and published after setting environment variables.
Run npx create-next-app --example blog-with-comment to generate the project. Copy .env.local.example to .env.local, then create an Upstash database and copy its REDIS_URL into the file. In the Auth0 dashboard, create a Single Page Web Application and set the Allowed Callback URLs, Allowed Logout URLs, and Allowed Web Origins to http://localhost:3000/ for local testing or your production domain. Add the Auth0 domain, client ID, and admin email to the environment variables, then deploy by importing the repository into Vercel and configuring the same variables in the project settings.
Yes. The comment box requires users to sign in with Auth0. Only authenticated users can add new comments, which means anonymous visitors cannot post.
A regular user can delete only their own comment. The admin user, identified by the NEXT_PUBLIC_AUTH0_ADMIN_EMAIL environment variable, can delete any comment on the blog.
Comments are stored in Upstash Serverless Redis. You create a database in the Upstash Console and supply its connection URL via the REDIS_URL environment variable.
Push the project to GitHub, GitLab, or Bitbucket, then import it into Vercel. In the Vercel project settings, set the same environment variables (REDIS_URL, NEXT_PUBLIC_AUTH0_DOMAIN, NEXT_PUBLIC_AUTH0_CLIENT_ID, and NEXT_PUBLIC_AUTH0_ADMIN_EMAIL) that you used locally.
Yes. This is an official example from the vercel/next.js repository, extending the base Next.js blog example with comment functionality. The repository has over 141,000 stars.
