VercelLogotypeVercelLogotype
LoginSign Up
Back to Templates

Whop SaaS Template

A simple way to sell access to your Next.js App, built with the Whop SDK

DeployView Demo
Whop Next.js Template Thumbnail Image

This is a Next.js project created using the whop-next-template

Getting Started

First, set the required environment variables:

NEXT_PUBLIC_WHOP_CLIENT_ID="WHOP CLIENT ID"
WHOP_CLIENT_SECRET="WHOP CLIENT SECRET"
WHOP_API_KEY="WHOP API KEY"
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="NEXTAUTH SECRET"
NEXT_PUBLIC_RECOMMENDED_PLAN_ID="PLAN ID"
NEXT_PUBLIC_REQUIRED_PRODUCT="PRODUCT ID"

Many of the environment variables can be found here

Run locally

Pull your reposity

Then, install node modules:

pnpm i

Then, run the development server:

pnpm run dev

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

This template offers examples on how to utilize next.js patterns in conjuction with @whop-sdk/core to easily gate certain parts of your website.

Included exmples:

/pages (Server-side rendered):

The examples in this list show how to use getServerSideProps in the pages directoy

  • pages/ssr/index.tsx - Adds the whop User to the page props. It renders a login button for logged-out users and a logout button for logged-in users
  • pages/ssr/logged-in.tsx - Only displays a page to logged-in users. If a logged-out user tries to access this page they will be redirected to /ssr where they can log in
  • pages/ssr/product-gated.tsx - Check if a user owns a specific Product and only shows the page content if they do. If the user does not own the product a button directing the user to the whop.com checkout page where they can buy a plan that unlocks the page.

/pages (Statically rendered):

  • pages/ssg/product-gated.tsx - This example shows how to use middleware to prevent users without access to a certain Product to visit this page. If a user that does not have access tries to request this page the middleware will redirect them to the whop.com checkout page where they can buy a plan that unlocks the page.

/app:

The examples in this list show how to use @whop-sdk/core in the new app directory added in next@13.0.0

  • app/app/ssr/page.tsx: This page shows how to obtain a user-scoped instaince of the WhopSDK UserService. If its able to obtain the sdk (the user is logged-in) it shows a logout button, if not it shows a login button
  • app/app/ssr/product-gated/layout.tsx: This layout shows how to lock a layout (and its children) for users that don't own a specific product. If no product is owned it renders a button that allows the user to purchase a product unlocking the layout on whop.com
  • app/app/ssr/product-gated/page.tsx: This page is product-gated without any extra setup as its parent layout(app/app/ssr/product-gated/layout.tsx) is already product-gated
  • app/app/ssg/product-gated/page.tsx: This page is protected by middleware, conceptually similar to pages/ssg/product-gated.tsx

/api:

  • pages/api/product-gated.ts: This api route uses the user session to obtain a user-scoped instance of the WhopSDK UserService and then uses that to check if the authorised used owns a certain product.

Learn More

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

  • WhopSDK Documentation - learn about Whop API features and how to use the SDK.
  • Next.js Documentation - learn about Next.js features and API.
  • Learn Next.js - an interactive Next.js tutorial.

You can check out this templates' GitHub repository - your feedback and contributions are welcome!

GitHub Repowhopio/next-template
Use Cases
EcommerceSaaSAuthentication
Stack
Next.jsCSS Modules
Auth
Whop Auth

Related Templates

Get Started

  • Templates
  • Supported frameworks
  • Marketplace
  • Domains

Build

  • Next.js on Vercel
  • Turborepo
  • v0

Scale

  • Content delivery network
  • Fluid compute
  • CI/CD
  • Observability
  • AI GatewayNew
  • Vercel AgentNew

Secure

  • Platform security
  • Web Application Firewall
  • Bot management
  • BotID
  • SandboxNew

Resources

  • Pricing
  • Customers
  • Enterprise
  • Articles
  • Startups
  • Solution partners

Learn

  • Docs
  • Blog
  • Changelog
  • Knowledge Base
  • Academy
  • Community

Frameworks

  • Next.js
  • Nuxt
  • Svelte
  • Nitro
  • Turbo

SDKs

  • AI SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDK
  • Streamdown AINew

Use Cases

  • Composable commerce
  • Multi-tenant platforms
  • Web apps
  • Marketing sites
  • Platform engineers
  • Design engineers

Company

  • About
  • Careers
  • Help
  • Press
  • Legal
  • Privacy Policy

Community

  • Open source program
  • Events
  • Shipped on Vercel
  • GitHub
  • LinkedIn
  • X
  • YouTube

Loading status…

Select a display theme:
    • AI Cloud
      • v0

        Build applications with AI

      • AI SDK

        The AI Toolkit for TypeScript

      • AI Gateway

        One endpoint, all your models

      • Vercel Agent

        An agent that knows your stack

      • Sandbox

        AI workflows in live environments

    • Core Platform
      • CI/CD

        Helping teams ship 6× faster

      • Content Delivery

        Fast, scalable, and reliable

      • Fluid Compute

        Servers, in serverless form

      • Observability

        Trace every step

    • Security
      • Bot Management

        Scalable bot protection

      • BotID

        Invisible CAPTCHA

      • Platform Security

        DDoS Protection, Firewall

      • Web Application Firewall

        Granular, custom protection

    • Company
      • Customers

        Trusted by the best teams

      • Blog

        The latest posts and changes

      • Changelog

        See what shipped

      • Press

        Read the latest news

      • Events

        Join us at an event

    • Learn
      • Docs

        Vercel documentation

      • Academy

        Linear courses to level up

      • Knowledge Base

        Find help quickly

      • Community

        Join the conversation

    • Open Source
      • Next.js

        The native Next.js platform

      • Nuxt

        The progressive web framework

      • Svelte

        The web’s efficient UI framework

      • Turborepo

        Speed with Enterprise scale

    • Use Cases
      • AI Apps

        Deploy at the speed of AI

      • Composable Commerce

        Power storefronts that convert

      • Marketing Sites

        Launch campaigns fast

      • Multi-tenant Platforms

        Scale apps with one codebase

      • Web Apps

        Ship features, not infrastructure

    • Tools
      • Marketplace

        Extend and automate workflows

      • Templates

        Jumpstart app development

      • Partner Finder

        Get help from solution partners

    • Users
      • Platform Engineers

        Automate away repetition

      • Design Engineers

        Deploy for every idea

  • Enterprise
  • Pricing
Log InContact
Sign Up
Sign Up
Back to Templates
DeployView Demo

Next.js Commerce

Starter kit for high-performance commerce with Shopify.
Next.js Commerce

SvelteKit Commerce

An all-in-one starter kit for high-performance e-commerce sites built with SvelteKit.
SvelteKit Commerce

Stripe Subscription Starter

The all-in-one subscription starter kit for high-performance SaaS applications, powered by Stripe, Supabase, and Vercel.
Stripe Subscription Starter
v0

Build applications with AI

AI SDK

The AI Toolkit for TypeScript

AI Gateway

One endpoint, all your models

Vercel Agent

An agent that knows your stack

Sandbox

AI workflows in live environments

CI/CD

Helping teams ship 6× faster

Content Delivery

Fast, scalable, and reliable

Fluid Compute

Servers, in serverless form

Observability

Trace every step

Bot Management

Scalable bot protection

BotID

Invisible CAPTCHA

Platform Security

DDoS Protection, Firewall

Web Application Firewall

Granular, custom protection

Customers

Trusted by the best teams

Blog

The latest posts and changes

Changelog

See what shipped

Press

Read the latest news

Events

Join us at an event

Docs

Vercel documentation

Academy

Linear courses to level up

Knowledge Base

Find help quickly

Community

Join the conversation

Next.js

The native Next.js platform

Nuxt

The progressive web framework

Svelte

The web’s efficient UI framework

Turborepo

Speed with Enterprise scale

AI Apps

Deploy at the speed of AI

Composable Commerce

Power storefronts that convert

Marketing Sites

Launch campaigns fast

Multi-tenant Platforms

Scale apps with one codebase

Web Apps

Ship features, not infrastructure

Marketplace

Extend and automate workflows

Templates

Jumpstart app development

Partner Finder

Get help from solution partners

Platform Engineers

Automate away repetition

Design Engineers

Deploy for every idea