Can Livewire consume an API Laravel?

I am beggining to use livewire with laravel, a didnt see anything about this. Could you please tell me how i could use livewire in that way? there are some videotutorial for it?. I would like create a app in Laravel for multiple platforms (using livewire and tailwindcss for web app in frontend, but i want to have the API ready for Android or IOS fronted frameworks), i hope i can make me understand.

Thank you!

Livewire it’s just a package after all, and with it, you don’t need to create an extra API’s to handle SPA application for example or something like that, you can use it just in only a form in your entire application and it’s OK

You can use livewire in desktop version, and with the resources API uses the normal laravel controllers.

Website

// routes/web.php
Route::get('posts', PostIndex::class)->name('post.index') // livewire way

for phone for example

routes/api.php
Route::get('posts', App\Http\Controllers\PostController::class, ['index']); // laravel 8 way

thanks,

so will i need replicate the routes and controllers in a future when i will want create the same app for android?

In all cases if you want to consume the API, you have to look at api.php file and setup some resources with custom controller, so yeah you need to.

P.S: you must take some times for peaking the right tools for your application before you start creating it, the planing Part is the most important step.

thanks again! In the beggining, i was thinking learn react.js and make an API laravel backend. For desktop and mobile web react.js will be ok to consume the API, and for Android an IOS react-native for consume the API, so i will not need replicate all controllers and routes.

But i saw livewire and it is so simple, and i would like use liveware instead of learn React.js

In my opinion, No need to learn new technology just for use it in a project, use what you are good for, for example, if you know VueJs use NuxtJS as a front-end and Laravel to handle the API’s for both NuxtJS and the Mobile Application

thank you again, I am old school :), still i use jquery and bootstrap. I am thinking use livewire and tailwindcss and in the future if i need apps for android or ios i will see. what do you think?

Yeah, it’s totally fine you can use Bootstrap, jQuery or TALL Stack and the API it’s another thing to take care of, depend on your project and the requirement.
I highly recommend Learning tailwindcss and livewire with AlpineJS because it’s easy to learn IMHO, and for the mobile app you can build the API’s later on.

ok thank you for you recommendation :slight_smile:
have a nice day!!

You are very welcome mate!
Have a nice day too :wink: