payloadcms

redirects

Official
by payloadcms
payload
Redirects & URLs
v3
v4
4.0.0-canary.20261205 · prerelease
MIT

Overview

Summary generated from the README

Adds a redirects collection to Payload so editors can manage URL redirects in the admin panel. Each redirect can point to a document in configured collections or to a custom URL, with optional redirect types such as 301 and 302. Your frontend queries the collection and applies the redirects, for example in Next.js middleware.

Features

  • Redirects collection with from URL and destination fields
  • Internal reference redirects to documents in chosen collections
  • External redirects using custom URLs
  • Optional redirect types such as 301 and 302
  • Overrides for the collection config and the redirect type field
  • Built-in English, French and Spanish translations with custom overrides

Use cases

  • Preserve old URLs by redirecting them to new pages after a site restructure
  • Let editors create redirects without developer involvement
  • Apply redirects in Next.js middleware using data from the Payload API

From the author

Redirects plugin for Payload

Installation

npm i @payloadcms/plugin-redirects

46.1k

Stars

4.5k

Forks

1821

Open Issues

Today

Last Updated

200.1k

Weekly Downloads

v3.94.2

npm Version

37.1 KB

Unpacked Size

2

Dependencies

Repository stars

46.1K+1.8K since Sep 7

Show data
Repository stars by day (UTC)
DateStars
Dec 6, 202646,145
Dec 5, 202646,136
Dec 4, 202646,125
Dec 3, 202646,106
Dec 2, 202646,087
Dec 1, 202646,068
Nov 30, 202646,059
Nov 29, 202646,037
Nov 28, 202646,035
Nov 27, 202646,022
Nov 26, 202646,012
Nov 25, 202645,993
Nov 24, 202645,976
Nov 23, 202645,958
Nov 22, 202645,947
Nov 21, 202645,937
Nov 20, 202645,926
Nov 19, 202645,901
Nov 18, 202645,868
Nov 17, 202645,852
Nov 16, 202645,831
Nov 15, 202645,820
Nov 14, 202645,807
Nov 13, 202645,792
Nov 12, 202645,779
Nov 11, 202645,763
Nov 10, 202645,742
Nov 9, 202645,731
Nov 8, 202645,722
Nov 7, 202645,704
Nov 6, 202645,681
Nov 5, 202645,670
Nov 4, 202645,647
Nov 3, 202645,629
Nov 2, 202645,611
Nov 1, 202645,603
Oct 31, 202645,592
Oct 30, 202645,574
Oct 29, 202645,561
Oct 28, 202645,543
Oct 27, 202645,519
Oct 26, 202645,492
Oct 25, 202645,472
Oct 24, 202645,449
Oct 23, 202645,430
Oct 22, 202645,405
Oct 21, 202645,259
Oct 20, 202645,239
Oct 19, 202645,213
Oct 18, 202645,192
Oct 17, 202645,165
Oct 16, 202645,148
Oct 15, 202645,122
Oct 14, 202645,100
Oct 13, 202645,082
Oct 12, 202645,057
Oct 11, 202645,032
Oct 10, 202645,023
Oct 9, 202645,003
Oct 8, 202644,983
Oct 7, 202644,959
Oct 6, 202644,935
Oct 5, 202644,924
Oct 4, 202644,907
Oct 3, 202644,891
Oct 2, 202644,876
Oct 1, 202644,859
Sep 30, 202644,846
Sep 29, 202644,829
Sep 28, 202644,805
Sep 27, 202644,787
Sep 26, 202644,769
Sep 25, 202644,737
Sep 24, 202644,709
Sep 23, 202644,691
Sep 22, 202644,669
Sep 21, 202644,641
Sep 20, 202644,628
Sep 19, 202644,609
Sep 18, 202644,595
Sep 17, 202644,570
Sep 16, 202644,548
Sep 15, 202644,523
Sep 14, 202644,501
Sep 13, 202644,488
Sep 12, 202644,470
Sep 11, 202644,447
Sep 10, 202644,427
Sep 9, 202644,402
Sep 8, 202644,384
Sep 7, 202644,364

Shared by 12 plugins in payloadcms/payload.

npm weekly downloads

196.8K+57.3K since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 2026196,819
Dec 5, 2026193,670
Dec 4, 2026189,650
Dec 3, 2026188,298
Dec 2, 2026190,498
Dec 1, 2026195,070
Nov 30, 2026198,768
Nov 29, 2026204,811
Nov 28, 2026212,928
Nov 27, 2026218,019
Nov 26, 2026222,737
Nov 25, 2026225,137
Nov 24, 2026223,736
Nov 23, 2026225,090
Nov 22, 2026222,560
Nov 21, 2026224,997
Nov 20, 2026227,035
Nov 19, 2026225,317
Nov 18, 2026223,317
Nov 17, 2026220,742
Nov 16, 2026219,952
Nov 15, 2026223,576
Nov 14, 2026224,782
Nov 13, 2026227,864
Nov 12, 2026224,573
Nov 11, 2026219,840
Nov 10, 2026220,824
Nov 9, 2026217,653
Nov 8, 2026217,243
Nov 7, 2026215,061
Nov 6, 2026211,315
Nov 5, 2026210,944
Nov 4, 2026215,294
Nov 3, 2026218,356
Nov 2, 2026224,693
Nov 1, 2026223,694
Oct 31, 2026223,720
Oct 30, 2026220,905
Oct 29, 2026184,890
Oct 28, 2026146,591
Oct 27, 2026147,817
Oct 26, 2026144,468
Oct 25, 2026144,570
Oct 24, 2026140,603
Oct 23, 2026105,506
Oct 22, 2026147,280
Oct 21, 2026180,921
Oct 20, 2026177,324
Oct 19, 2026174,766
Oct 18, 2026171,020
Oct 17, 2026171,937
Oct 16, 2026207,263
Oct 15, 2026202,433
Oct 14, 2026200,415
Oct 13, 2026195,931
Oct 12, 2026197,026
Oct 11, 2026196,497
Oct 10, 2026200,292
Oct 9, 2026200,662
Oct 8, 2026195,023
Oct 7, 2026196,087
Oct 6, 2026198,598
Oct 5, 2026196,339
Oct 4, 2026195,246
Oct 3, 2026189,168
Oct 2, 2026185,487
Oct 1, 2026186,904
Sep 30, 2026182,445
Sep 29, 2026178,064
Sep 28, 2026175,246
Sep 27, 2026167,897
Sep 26, 2026159,442
Sep 25, 2026154,852
Sep 24, 2026147,933
Sep 23, 2026145,173
Sep 22, 2026144,536
Sep 21, 2026144,190
Sep 20, 2026149,446
Sep 19, 2026151,726
Sep 18, 2026147,335
Sep 17, 2026145,779
Sep 16, 2026139,494
Sep 15, 2026140,595
Sep 14, 2026139,365
Sep 13, 2026132,135
Sep 12, 2026128,281
Sep 11, 2026129,921
Sep 10, 2026134,619
Sep 9, 2026140,390
Sep 8, 2026140,150
Sep 7, 2026139,483

Each point is npm's rolling 7-day download count.

Health Score

100/100Excellent

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/official-plugin-redirects.svg)](https://payloaddirectory.dev/plugins/official-plugin-redirects)
HTML
<a href="https://payloaddirectory.dev/plugins/official-plugin-redirects"><img src="https://payloaddirectory.dev/badge/official-plugin-redirects.svg" alt="Payload Directory"></a>
Updated Dec 5, 2026Created Jan 5, 2021Published Nov 24, 2026

README

Payload Redirects Plugin

A plugin for Payload to easily manage your redirects from within your admin panel.

Features

  • Manage redirects directly from your admin panel
  • Support for internal (reference) and external (custom URL) redirects
  • Built-in multi-language support
  • Optional redirect types (301, 302, etc.)

Installation

pnpm add @payloadcms/plugin-redirects

Basic Usage

In your Payload Config, add the plugin:

import { buildConfig } from 'payload'
import { redirectsPlugin } from '@payloadcms/plugin-redirects'

export default buildConfig({
  plugins: [
    redirectsPlugin({
      collections: ['pages'], // Collections to use in the 'to' relationship field
    }),
  ],
})

Configuration

Options

OptionTypeDescription
collectionsstring[]An array of collection slugs to populate in the to field of each redirect.
overridesobjectA partial collection config that allows you to override anything on the redirects collection.
redirectTypesstring[]Provide an array of redirects if you want to provide options for the type of redirects to be supported.
redirectTypeFieldOverrideFieldA partial Field config that allows you to override the Redirect Type field if enabled above.

Advanced Example

import { buildConfig } from 'payload'
import { redirectsPlugin } from '@payloadcms/plugin-redirects'

export default buildConfig({
  plugins: [
    redirectsPlugin({
      collections: ['pages', 'posts'],

      // Add custom redirect types
      redirectTypes: ['301', '302'],

      // Override the redirects collection
      overrides: {
        slug: 'custom-redirects',

        // Add custom fields
        fields: ({ defaultFields }) => {
          return [
            ...defaultFields,
            {
              name: 'notes',
              type: 'textarea',
              admin: {
                description: 'Internal notes about this redirect',
              },
            },
          ]
        },
      },
    }),
  ],
})

Custom Translations

The plugin automatically includes translations for English, French, and Spanish. If you want to customize existing translations or add new languages, you can override them in your config:

import { buildConfig } from 'payload'
import { redirectsPlugin } from '@payloadcms/plugin-redirects'

export default buildConfig({
  i18n: {
    translations: {
      // Add your custom language
      de: {
        'plugin-redirects': {
          fromUrl: 'Von URL',
          toUrlType: 'Ziel-URL-Typ',
          internalLink: 'Interner Link',
          customUrl: 'Benutzerdefinierte URL',
          documentToRedirect: 'Dokument zum Weiterleiten',
          redirectType: 'Weiterleitungstyp',
        },
      },
      // Or override existing translations
      fr: {
        'plugin-redirects': {
          fromUrl: 'URL source', // Custom override
        },
      },
    },
  },

  plugins: [
    redirectsPlugin({
      collections: ['pages'],
    }),
  ],
})

Using Redirects in Your Frontend

The plugin creates a redirects collection in your database. You can query this collection from your frontend and implement the redirects using your framework's routing system.

Example: Next.js Middleware

// middleware.ts
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'

export async function middleware(request: NextRequest) {
  const { pathname } = request.nextUrl

  // Fetch redirects from Payload API
  const redirects = await fetch('http://localhost:3000/api/redirects', {
    next: { revalidate: 60 }, // Cache for 60 seconds
  }).then((res) => res.json())

  // Find matching redirect
  const redirect = redirects.docs?.find((r: any) => r.from === pathname)

  if (redirect) {
    const destination =
      redirect.to.type === 'reference'
        ? redirect.to.reference.slug // Adjust based on your collection structure
        : redirect.to.url

    return NextResponse.redirect(
      new URL(destination, request.url),
      redirect.type === '301' ? 301 : 302,
    )
  }

  return NextResponse.next()
}

Similar plugins

View on GitHubView on npmOfficial Payload plugin