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

niiwill's avatar

Redirect after registration Laravel 8

Hi folks,

I want to redirect the user after successful registration to one more page before the admin page.

Where I can redirect after successful registration in the Laravel 8 jetstream app and only after registration not login etc.

Thank you in advance.

0 likes
7 replies
niiwill's avatar

No, I need after registration redirect not after login.. thank you

MA's avatar

The logic is the same as the LoginResponse, you just have to replace the RegisterResponse class with your own.

1 like
MichalOravec's avatar
Level 75

Create app/Http/Responses/RegisterResponse.php

<?php

namespace App\Http\Responses;

use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
use Laravel\Fortify\Contracts\RegisterResponse as RegisterResponseContract;

class RegisterResponse implements RegisterResponseContract
{        
    public function toResponse($request)
    {
        // below is the existing response
        // replace this with your own code

        return $request->wantsJson()
                    ? new JsonResponse('', 201)
                    : redirect(config('fortify.home'));
    }
}

In JetstreamServiceProvider in the boot method register it

public function boot()
{
    // other code

    // register new RegisterResponse
    $this->app->singleton(
        \Laravel\Fortify\Contracts\RegisterResponse::class,
        \App\Http\Responses\RegisterResponse::class
    );
}
2 likes
bojan_s's avatar

This is very helpful. I need users to register before they they check out so I needed to redirect back to the checkout page once they log in. If the user was not registered and they went to check out, I would add the current url to the session as the intended url and then in the RegisterResponse I would redirect if there was an intended url. This is in my checkout controller

    if (auth()->guest()) {
        session()->flash('error', 'Register first');
        session()->put('url.intended', $request->fullUrl());
        return redirect()->route('register');
    }

This is in my RegisterResponse

public function toResponse($request)
{
    return $request->wantsJson()
        ? new JsonResponse('', 202)
        : redirect()->intended(config('fortify.home'));
}

Works like a charm

Please or to participate in this conversation.