This repository replicates Build Modern Laravel Apps Using Inertia.js series from Laracasts, using Laravel 11 and TypeScript.
I recommend using this repository as supplementary material while referring to the original video.
If you find this repository helpful, please give it a star! ⭐ It would really boost my motivation. Thank you!
Each episode is represented by a separate branch. Switch between branches to follow along with the series.
The following sections includes:
- Todos
- Key points
Switch branches and complete the Todos to easily review and practice the concepts.
npm run dev
php artisan serve
- Create a new Laravel project with
laravel new - Complete server-side setup. Note that
Kernel.phpis not present in Laravel 11. - Complete client-side setup. Also, add typescript support. The easiest way to do this is to create temporary vue project with
npm install @inertiajs/vue3, then copy the files and merge the settings. Ensure you update several files likepackage.json,.editorconfig,vite.config.ts, etc. Change*.jsto*.ts.
@inertia- How the
InertiaAppresolves*.vuefile.
- Create
Welcome.vueand show "Hello World". - Pass name prop from Laravel to frontend. Show "Hello, ${name}"
- Rename
Welcome.vuewithHome.vue. - Pass frameworks prop from Laravel and show all of them.
inertia/Inertia::renderfunctions.- Vue.js devtools
- How to get props from Laravel.
- Create
/usersand/settingspages. Display "Users" and "Settings" in the respective page heading. - Create a navigation bar (
nav) inHome.vuethat links to each page. Prevent page reloads during transitions. Verify SPA functionality by adding 2-second delay in/userendpoint. - Create reusable
Nav.vuecomponent and import it into each pages.
- Distinguish between standard anchor tags and Inertia's Link component.
- Explore the typical Inertia directory structure.
Note: Inertia now includes default progress indicator.
- Customize the progress indicator by changing its color and displaying a spinner. Refer to the official document for more details.
- Techniques for customizing the progress indicator.
- Implement
/logoutendpoint. Upon receiving a POST request, display a "logging out" message withdd. Add a logout button toNav.vue. - Apply tailwind styling to
Home.vueandNav.vue.- Increase the font size and weight of heading in
Home.vue. - Add padding to the entire page.
- Style links to appear blue and display an underline on hover.
- Increase the font size and weight of heading in
- Method for sending HTTP requests other than GET.
- Display the current server-side time in
Users.vue. - Add top margin to require scrolling to view the time.
- Include a "Refresh" link. Maintain the current scroll position after refreshing the page.
- Techniques for preserving the user's scroll position when navigating a page.
- Investigate Inertia component's props with vue devtools.
- Highlight the links in
Nav.vuewhen the current page URL matches the link's URL. - Create reusable
NavLink.vueto simplify the implementation.
- Props of Inertia component.
- Create
Layout.vueand apply taiwlind styles.
- Reusable components.
- Add user data that can be accessed from any page. For now, hardcode a username.
- Display "Welcome Back, {username}!" message in navigation bar.
- Define the type of shared data.
- Use computed prop for username.
- Method for sharing data across all pages, including conventions and potential risk.
- How to define the type of
PageProps.
- Make Link component globally accessible without requiring an import statement.
- The usage of App.component.
- Make the Layout component persistent. Test if that works correctly by embedding the following iframe with the Layout component.
<iframe
class="mb-6"
width="100%"
frameborder="no"
scrolling="no"
seamless
src="https://player.simplecast.com/fd0bd2ba-c553-466c-a060-b144797ce369?dark=false"
/>- Challenges of nesting layout component within page component.
- The idea of persistent component.
- Implement a default layout.
- Allow for overriding the default layout when a layout is provided.
- The mechanism for supplying overriding page props.
- Apply vendor extraction.
- Apply code splitting.
- The idea of vendor extraction.
- Remove iframe in Layout.vue.
- Add page-specific titles.
- Set a default title.
- Set a default meta description and override it from Home.vue.
- Add "My App - " prefix to every page title.
- Make the Head component accessible without requiring import.
- Head component
- Dynamic Title
- Meta tags.
- Create 100 dummy user data with Laravel's Seeder.
- Show all users in
/users. - Hide unnecessary user information.
- Security Issues of passing all data from backend.
- Difference between SPA and traditional server-side application.
- Apply table style provided by Tailwind to users table.
- Check the result of
User::paginate()and implement pagination. If the paginator element contains link, then display anchor. Otherwise, show span. Gray out the span since it's not clickable. Highlight the current page number. Hint: use Component. - Create reusable
Pagination.vuecomponent. - Only pass users' id and name to the frontend.
- How to use pagination in Inertia.
- How to filter the props in pagination.
- Add and input element next to the "Users" heading.
- When the input is changed, show the content in the console.
- When the input is changed, send get request to the backend. Don't lose the inputted text on page transition.
- Handle query in the backend. Ensure that the query string is preserved when navigating to another page.
- Set the default value of the input to search query.
- Prevent pages from being added to history every time an input is entered.
- How to handle query in Inertia and Laravel.
- Create a vue file for page to create a new user. Refactor the directory structure.
- Implement frontend and backend logic for creating a new user.
- Directory structure for Inertia.
- How to create a form in vue and inertia.
- Add a link to create a new user in
/users. - Show error messages if the validation in server-side failed.
- How to show validation error messages in Inertia.
- Make the submit button disabled when the button is pressed.
- Achieve the same things with inertia's form helper.
- Problems of the form in the previous episode.
- Inertia's form helper.
- Use throttle to limit get requests.
- Use debounce to limit get requests.
- [ ]
- Two ways to limit too frequent get requests and their difference.
- Make all the routes created so far require login.
- Create a route to
/loginand LoginController. - Implement the login functionality for the frontend and backend.
- Display the actual username to the heading.
- Create a logout link to the navigation bar.
redirect()->intended()- How to handle authentication in Inertia.
- Display the “New User” link only when the logged-in user’s email address matches a specific value.
- Make
/users/createaccessible only to the authorized user. - Implement a policy to determine whether the logged-in user can edit other users, and handle the implementation on both the frontend and backend. However, it’s fine to randomize who can edit whom.
- How to pass authorization info from the backend to the frontend
- Authorization in Laravel
This was already done.
This was almost done already.
- Split Pagination in Users/Index.vue from Index.
- How to split the build files.
- Create an endpoint
/users/{user}and its corresponding view. - Take measures in case you forget to serialize.
- The Importance of Serialization / The Risks of Not Serializing and Its Good Practices.