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

Sam's avatar
Level 4

Vue JS SPA & Laravel API - Confused

Hi guys,

I seem to be having a little bit of a brain cloud moment.

So basically I have a very simple website I am building in Vuejs. I then want to call out to a Laravel API to save and retrieve some records from a database. There's no user login etc, just purely, storing and retrieval of records.

With this in mind what is the best approach here in terms of protecting the routes - from the VueJS app I believe I should be passing and API key to the Laravel App, im just unsure what package aids this from laravels point of view?

Please can someone help me overcome my brain cloud here please?

0 likes
3 replies
Sam's avatar
Level 4

Thanks @nakov I did wonder whether sanctum was the right to go.

So say I wanted to get a list of books, I would just protect that with the auth:sanctum middleware and ensure that sanctum is setup correctly then I should in theory, receive said list of books without actually providing any token or anything?

Cheers

Nakov's avatar

@Sam yes, as long as you own both the frontend and the backend, and set it up as the documentation says you are good to go. Your API will be protected and allowed to be used just by you. Have fun!

Please or to participate in this conversation.