How to use Liveblocks with Astro
When adding Liveblocks to Astro apps, it's recommended to
use
client:only
with your components. This is recommended because Liveblocks only needs on the
client, and in Astro, you may run into bundling issues if the app is rendered on
both the server and client.
Example
Here's an example of client:only
used with various frameworks:
Not required with .astro components
Note that when using .astro
components and the <script>
tag, client:only
is not necessary, because it always runs on the client:
Using @liveblocks/react with Astro
Note that when using our React package with Astro, RoomProvider
does not work
in nested .astro
files, as each component is a separate "island", and cannot
see the context in another island. Each React root in .astro
files is like a
new React app, and will need its own RoomProvider
.