Agility CMS documentationAgility CMS documentation
OverviewEditorsDevelopersOwners & AdminsTraining GuideApps
Sign inLet's Chat
Next.js
Multi-Locale Support with Next.jsGoogle Analytics and Next.jsDeploying Next.js to VercelDeploying Next.js to NetlifyDeploying Next.js to AWS EC2Deploying Next.js to AWS AmplifyDeploying Next.js on AzureUsing Storybook.js with Agility CMS and Next.jsRendering & Data Fetching with Next.jsImplementing Pagination with Next.jsImplementing URL Redirects with Next.jsImplementing a Custom 404 Page with Next.jsImplementing JSON-LD Structured Data with Next.jsUsing the AgilityPic Component for Responsive Images

Tutorials

Implementing URL Redirects with Next.js

Configuring URL Redirects within your website is essential for Content Editors who want to manage URL Redirections in Agility CMS to provide a way for redirecting a user from one URL to another URL.

Setting up URL Redirects in Next.js is fairly easy. Within the next.config.js file, can use the getUrlRedirections API Call from our @agility/content-fetch package to fetch our redirect from Agility, and configure them within our website.

In next.config.js:

const agility = require("@agility/content-fetch");

const api = agility.getApi({
  guid: process.env.AGILITY_GUID,
  apiKey: process.env.AGILITY_API_FETCH_KEY,
});

const getRedirects = async () => {
  try {
    return (redirects = await api.getUrlRedirections({}));
  } catch (e) {
    console.log(e);
  }
};

module.exports = {
  async redirects() {
    const { items } = await getRedirects();

    const redirects = items.map((redirect) => {
      let permanent;

      const source = redirect.originUrl.replace("~", "");
      const destination = redirect.destinationUrl.replace("~", "");

      if (redirect.statusCode === 301) {
        permanent = true;
      } else {
        permanent = false;
      }

      return {
        source,
        destination,
        permanent,
      };
    });

    return redirects;
  },
};

Learn more about redirects in Agility CMS here.

← Previous
Implementing Pagination with Next.js
Next →
Implementing a Custom 404 Page with Next.js
Agility CMS documentationAgility CMS documentation

Documentation for the CMS built for editors, developers, and AI agents.

Docs
  • Overview
  • Editors
  • Developers
  • Owners & Admins
  • Training Guide
  • Changelog
Resources
  • Get Support
  • MCP Server
  • System Status
  • llms.txt
Agility
  • agilitycms.com
  • Start Free Trial
  • Sign in
  • Blog
© 2026 Agility Inc. All rights reserved.
Privacy PolicyTerms of Service