-
-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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
- Create a Next.js 16 project with this adapter
- Enable
cacheComponentsinnext.config:const nextConfig: NextConfig = { cacheComponents: true, }; export default nextConfig;
- 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('/');
});- 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>
);
}- 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.
jstri, MeesEgberts, TomLaVachette, dobbo5, mononoke-choi and 2 more
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working