The render() method

A Livewire component class needs only one method to function properly: render(). This method fires on every component update and is in charge of returning the Blade view to be rendered.

In simple components, you don't need to define a `render` method yourself. The base Livewire component class has a dynamic `render` method included.

Returning Blade

The render() method is expected to return a Blade view, therefore, you can compare it to writing a controller method. Here is an example:

Make sure your Blade views have only ONE root HTML element.
use Livewire\Component;

class ShowPosts extends Component
    public function render()
        return view('', [
            'posts' => Post::all(),
    @foreach ($posts as $post)
        @include('', $post)
Although `render()` methods closely resemble controller methods, there are a few techniques you are used to using in controllers that aren't available in Livewire components. Here are two common things you might forget ARE NOT possible in Livewire:
public function render()
    return back();
    // Or
    return ['some' => 'data'];
← Previous Topic

Making Components

Next Topic →

State Management