Skip to content

Alice39s/cloudflare-custom-pages-nextjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

37 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒ Cloudflare Custom Pages - Next.js

A set of elegant, out-of-the-box Cloudflare WAF Custom Page Templates implemented using Next.js, Tailwind CSS, and HeroUI. Built with Next.js 15, TypeScript, and Tailwind CSS, featuring responsive design, dark mode support, and automatic Cloudflare variable replacement.

English | ็ฎ€ไฝ“ไธญๆ–‡ | Online Demo

Tip

Please comply with the project's Open Source License when making modifications.

๐Ÿ“ธ Screenshots

Preview
Main Page
Example Page Light Mode Dark Mode
IP Block
JS Challenge
500s Error

โœจ Key Features

  • ๐ŸŽจ Modern Responsive Design: Sleek and contemporary layout optimized for all devices.
  • ๐ŸŒ™ Dark Mode Support: Automatically adapts to system preferences for comfortable viewing.
  • ๐Ÿ”’ Full Coverage of Cloudflare Page Types:
    • Block: WAF interception pages
    • Error: 1000s / 500s error pages
    • Captcha: CAPTCHA challenge pages
  • ๐Ÿ“ฑ Mobile-First Approach: Guaranteed smooth experience on mobile devices.
  • ๐ŸŽญ Automatic Cloudflare Variable Replacement: Seamless integration of Cloudflare-specific variables.

๐Ÿ› ๏ธ Tech Stack

  • Next.js 15 + React 19
  • HeroUI v2 + Tailwind CSS v3
  • TypeScript

๐ŸŽฏ Supported Variables

Currently supported automatic variable replacements:

  • ::CLIENT_IP:: - Client IP Address
  • ::RAY_ID:: - Cloudflare Ray ID
  • ::GEO:: - Client Geolocation
  • ::CLOUDFLARE_ERROR_500S_BOX:: - 500s Error Page Component
  • ::CLOUDFLARE_ERROR_1000S_BOX:: - 1000s Error Page Component
  • ::CAPTCHA_BOX:: - Cloudflare CAPTCHA Component
  • ::IM_UNDER_ATTACK_BOX:: - Cloudflare JavaScript Challenge Component

๐Ÿ”ญ Usage

Quickly access Cloudflare Custom Pages via this link.

Tip

Your Cloudflare zone must be on Pro plan or higher to use these templates.

Type Subtype Link
Error Pages Server Errors (500s) Import Link
CF 1000s Errors Import Link
Block Pages IP Block (1006) Import Link
WAF Block (1010) Import Link
Rate Limit Block (429) Import Link
Challenges Interactive Challenge Import Link
Managed Challenge (I'm Under Attack Modeโ„ข) Import Link
Country/Region Challenge Import Link
JavaScript Challenge Import Link

๐ŸŒ Deployment Guide

  • Deploy to Vercel (Recommended):

    Deploy with Vercel

  • Manual Deployment:

    bun run build
    # Ignore the following command if using Nginx/etc.
    bun run start

    bun run start launches a local server using serve@latest, listening on 0.0.0.0:3001 by default.

๐Ÿš€ Development Guide

  1. Install Bun:

    # macOS/Linux:
    curl -fsSL https://bun.sh/install | bash
    # Windows PowerShell:
    powershell -c "irm bun.sh/install.ps1 | iex"
  2. Clone Repository:

    git clone https://github.com/Alice39s/cloudflare-custom-pages-nextjs.git
  3. Install Dependencies:

    bun install
  4. Start Dev Server:

    bun dev
  5. Build Production Version:

    bun run build

๐ŸŽจ Customization Guide

1. Site Configuration

Modify fields in ./config/site.ts (name, description, etc.).

2. Content Customization

Translations of all texts can be modified in . /config/i18n.ts to change the translation of all texts (TODO: multi-language support).

To change the page text, edit . /config/i18n.ts:

export const blockPageTranslations = {
    ip: {
        title: "Access Denied - IP Blocked",
        message: "The owner of this website has banned your IP address.",
    },
    // ... more translations
};

To modify page configurations (without text content), edit ./config/routes.ts:

export const blockPages = {
    ip: {
        type: "ip",
        code: "1006",
        icon: "shield-ban",
        networkStatus: {
            clientStatus: "error",
            edgeStatus: "success",
        },
    },
    // ... more configurations
};

3. Component Styling

Project structure:

components/
โ”œโ”€โ”€ cf/        # ๐ŸŒฉ๏ธ Cloudflare Components
โ”œโ”€โ”€ home/      # ๐Ÿ  Homepage Components
โ””โ”€โ”€ layout/    # ๐Ÿ–ผ๏ธ Global Layout Components

4. Custom Icons

This project utilizes the lucide-react icon library. To optimize the project's size, we have encapsulated a unified entry point and on-demand loading component called Icon.

You can follow the steps below to add or replace icons:

  1. Check if the icon you want to use is not already listed in ./config/icons.ts. If it exists, skip directly to step 5.

  2. Visit the Lucide icon library and select your preferred icon.

  3. Click the Copy Component Name button to copy the icon's name.

  4. Then, navigate to ./config/icons.ts and follow the instructions to add the icon name to:

    1. import { ... Component } from "lucide-react" (import the icon component)
    2. export type IconKey = ... (add the icon name to the type list)
    3. export const icons = { ... } (add the icon name to the mapping dictionary)
  5. Finally, use the desired icon in ./config/routes.ts.

๐Ÿ“œ License

Licensed under GPL v3.0. See LICENSE for details.