Nextjs 13.4 permanentRedirect is not a function

257 Views Asked by At

I use pretty the same example as documentation does.

My full code (literally nothing more):

import React from "react";
import { redirect, permanentRedirect } from 'next/navigation'

export default function Index(params) {
  permanentRedirect('/licenseKeys')
}

For sure I can use redirect() function instead, but I need to mark this redirect as permanent.

I investigated the next/navigation file, and there is no permanentRedirect() function, only regular redirect().

This looks like some stupid mistake like "one wrong character", but I copy-pasted the example from Next.js documentation, and nothing changed. Maybe somebody knows where I am wrong? Or is it Next.js docs lie to us?

The error: permanentRedirect is not a function

1

There are 1 best solutions below

1
On BEST ANSWER

This function is documented but not released yet. It's already in the canary release. You can install it by npm install next@canary (use at your own risk).

The documentation of peremanentRedirect is made two weeks ago in this pull request But, the function is not yet released in a stable release.