You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 27, 2025. It is now read-only.
By default, Livewire injects the JavaScript and CSS assets it needs into each page that includes a Livewire component. If you want more control over this behavior, you can [manually include the assets](https://livewire.laravel.com/docs/installation#manually-including-livewires-frontend-assets) on a page using the following Antlers tags or Blade directives:
25
25
26
-
```html
26
+
```html
27
27
<html>
28
28
<head>
29
29
<!-- If using Antlers -->
30
30
{{ livewire:styles }}
31
-
31
+
32
32
<!-- If using Blade -->
33
33
@livewireStyles
34
34
</head>
35
35
<body>
36
-
36
+
37
37
...
38
38
<!-- If using Antlers -->
39
39
{{ livewire:scripts }}
40
-
40
+
41
41
<!-- Blade -->
42
42
@livewireScripts
43
43
</body>
@@ -47,21 +47,21 @@ By default, Livewire injects the JavaScript and CSS assets it needs into each pa
47
47
### Manually bundling Livewire and Alpine
48
48
If you need to include some custom Alpine plugins, you need to [manually bundle the Livewire and Alpine assets](https://livewire.laravel.com/docs/installation#manually-bundling-livewire-and-alpine) and disable the automatic injection by using the following Antlers tag or Blade directive. Do not forget to include the Livewire styles as well.
49
49
50
-
```html
50
+
```html
51
51
<html>
52
52
<head>
53
53
<!-- If using Antlers -->
54
54
{{ livewire:styles }}
55
-
55
+
56
56
<!-- If using Blade -->
57
57
@livewireStyles
58
58
</head>
59
59
<body>
60
-
60
+
61
61
...
62
62
<!-- If using Antlers -->
63
63
{{ livewire:scriptConfig }}
64
-
64
+
65
65
<!-- Blade -->
66
66
@livewireScriptConfig
67
67
</body>
@@ -77,6 +77,16 @@ This addon adds an `AssetsReplacer` class to make Livewire compatible with half
77
77
],
78
78
```
79
79
80
+
If you are using full measure static caching and you're manually bundling Livewire and Alpine as per the instructions above, you need to make sure to only start Livewire once the CSRF token has been replaced.
81
+
82
+
```js
83
+
if (window.livewireScriptConfig?.csrf==='STATAMIC_CSRF_TOKEN') {
You can create Livewire components as described in the [general documentation](https://livewire.laravel.com/docs/components).
99
+
You can create Livewire components as described in the [general documentation](https://livewire.laravel.com/docs/components).
90
100
To include your Livewire component:
91
101
```html
92
102
<body>
93
103
<!-- If using Antlers -->
94
104
{{ livewire:your-component-name }}
95
-
105
+
96
106
<!-- If using Blade -->
97
107
<livewire:your-component-name />
98
108
</body>
@@ -195,7 +205,7 @@ You can paginate results by using the WithPagination trait.
195
205
To use pagination with Blade, please use the `Livewire\WithPagination` namespace for your trait as described in the [Livewire docs](https://livewire.laravel.com/docs/pagination#basic-usage).
196
206
197
207
### Antlers
198
-
Pagination with Antlers does work similar. Make sure to use the `Jonassiewertsen\Livewire\WithPagination` namespace for your trait if working with Antlers.
208
+
Pagination with Antlers does work similar. Make sure to use the `Jonassiewertsen\Livewire\WithPagination` namespace for your trait if working with Antlers.
199
209
200
210
In your Livewire component view:
201
211
```html
@@ -230,7 +240,7 @@ class ShowArticles extends Component
230
240
```
231
241
232
242
### EXPERIMENTAL: Statamic Support
233
-
As a little experiment, support for an Entry or EntryCollection has been added, so you can make an entry or a entry collection simply a public property and it just works.
243
+
As a little experiment, support for an Entry or EntryCollection has been added, so you can make an entry or a entry collection simply a public property and it just works.
234
244
235
245
Supported types:
236
246
- Statamic\Entries\EntryCollection;
@@ -252,7 +262,7 @@ class Foo extends Component
252
262
}
253
263
```
254
264
255
-
To make it work, you need to enable that feature first.
265
+
To make it work, you need to enable that feature first.
256
266
257
267
1. php artisan vendor:publish
258
268
2. Select statamic-livewire in the list
@@ -263,14 +273,14 @@ In case you want to share state between Livewire and Alpine, there is a Blade di
It's worth mentioning that, since Livewire v3 now builds on top of Alpine, the `@entangle` directive is not documented anymore. Instead, it's possible to entangle the data via [the `$wire` object](https://livewire.laravel.com/docs/javascript#the-wire-object).
0 commit comments