Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ashwinmram's avatar

How do I redirect from Jetstream/Inertia to Laravel Nova's dashboard after login?

Since Jetstream uses Fortify under the hood, I believe I need to do the redirection in the Fortify Service Provider.

Here is what my code looks like:

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->instance(LoginResponse::class, new class implements LoginResponse
        {
            public function toResponse($request)
            {
                return $request->wantsJson()
                    ? response()->json(['two_factor' => false])
                    : $this->redirect($request);
            }

            private function redirect($request)
            {
                if ($request->access === 'setup') {
                    return redirect()->to('/nova');
                }

                return redirect()->to('/dashboard');
            }
        });
    }

I don't understand why, but when the access is 'setup' there is a 404 not found in an Inertia modal. If I click 'Go Home' in the modal, then it loads the Nova dashboard but still inside the modal.

I'm not sure why there is a 404 not found as I have registered the Nova Service Provider in app/config.php

Any thoughts suggestions will be appreciated!

0 likes
2 replies
ashwinmram's avatar
ashwinmram
OP
Best Answer
Level 27

I found the answer in the Inertia docs!

https://inertiajs.com/redirects

External redirects Sometimes it's necessary to redirect to an external website, or even another non-Inertia endpoint in your app, within an Inertia request.

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->instance(LoginResponse::class, new class implements LoginResponse
        {
            public function toResponse($request)
            {
                return $request->wantsJson()
                    ? response()->json(['two_factor' => false])
                    : $this->redirect($request);
            }

            private function redirect($request)
            {
                if ($request->access === 'setup') {
                    return Inertia::location('nova'); // Here is how it's done!
                }

                return redirect()->to('/dashboard');
            }
        });
    }

Please or to participate in this conversation.