Skip to content

[BUG] Server action redirects fail when Next.js 16 cacheComponents is enabled #393

@ramonmalcolm10

Description

@ramonmalcolm10

Are you using the latest version of this library?

  • I verified that the issue exists in the latest next-safe-action release

Is there an existing issue for this?

  • I have searched the existing issues and found nothing that matches

Describe the bug

When using Next.js 16 with cacheComponents: true enabled in next.config, server action redirects using redirect() from next/navigation do not work. The redirect is not executed and the user remains on the current page.

Reproduction steps

  1. Create a Next.js 16 project with this adapter
  2. Enable cacheComponents in next.config:
    const nextConfig: NextConfig = {
      cacheComponents: true,
    };
    export default nextConfig;
  3. Create a server action with a redirect:
'use server'

import { actionClient } from "@/lib/safe-action";
import { redirect } from "next/navigation";

export const create = actionClient
    .action(async () => {
    // Perform some action
    redirect('/');
});
  1. Use the action with useAction:
'use client'

import { useAction } from "next-safe-action/hooks";
import { create } from "./action";

export function MyForm() {
   const { execute } = useAction(create);
   return (
       <button
         onClick={() => execute()}>
         Create
       </button>
   );
}
  1. Click the button

Expected behavior

The redirect('/') call should navigate the user to the homepage after the server action completes.

Link to a minimal reproduction of the issue

https://github.com/ramonmalcolm10/next-safe-action-bug

Operating System

macOS

Library version

8.0.11

Next.js version

16.0.0

Node.js version

24.10.0

Additional context

The functionality worked as expected with direct execution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions