Focus in input field on page load with `x-init` in Alpine JS

Share this video with your friends

Send Tweet

In this lesson, we learn how the x-init directive in Alpine JS lets us run a JavaScript expression once the component has initiated.

We see the nuances that allow us to trigger that code before Alpine performs initial DOM updates, or after these updates have been made.