How to Change the Redirect Route after Login in Laravel Spark

Website Development

Christopher Wray

The past several days I spent some time searching Stack Overflow and Google for the answer to this question, so I thought you might appreciate it if I shared the answer here.

If you want to redirect users to a different route after login in Laravel Spark, I would not recommend trying to do it like you would with any other laravel app.

If you built a new Spark app with "spark new", you wont even have the login controller in your Http folder, and if you try changing your login controller in a Laravel app that had Spark added after, the way to change the login link will not work as described in the Laravel docs.

In order to change the login redirect route in Spark, it is actually really simple to do, but nowhere in the Spark docs will you see info on how to do it.

Steps to change redirect route.

  1. First, you need to go to your SparkServiceProvider in your app/Providers directory.
  2. Find the booted() method, and add the below code into that method.
Spark::afterLoginRedirectTo('new-route-here');

Just replace new-route-here with your intended route and you should be good to go.

Hope this helps!

Thanks so much for visiting our blog.

Do you want to know a secret?

Soltech is owned by me, Chris.

Right now, I am looking for a job.

Over the past couple of years, I have learned so much doing work for different small businesses both in Mexico and the United States.

It has been a huge blessing to work with many amazing people.

That being said, I want to hone in my craft in Software Development and Customer Service, which are two parts of my job here at Soltech that I have especially loved and want to grow in.

I am seeking a position where I could do one of those things more full time.

Are you hiring for one of those roles?

Find my contact info here and reach out if you are and interested in talking to me about joining your team.

Thanks so much for reading. I hope you enjoy the content here.

More For You

Send us an Email

We'd love to hear from you.

Thank you! Your submission has been received!

Oops! Something went wrong while submitting the form :(