# Quickstart - Get started with Liveblocks and Zustand

Liveblocks is a realtime collaboration infrastructure for building performant collaborative experiences. Follow the following steps to start making your Zustand store multiplayer by using the middleware from the [`@liveblocks/zustand`](/content/docs/api-reference/liveblocks-zustand/index.html) package.

## Quickstart

1. ### Install Liveblocks

Every Liveblocks package should use the same version.

#### Terminal

```text
npm install @liveblocks/client @liveblocks/zustand
```

2. ### Initialize the `liveblocks.config.ts` file

We can use this file later to [define types for our application](/content/docs/api-reference/liveblocks-react#Typing-your-data/index.html).

#### Terminal

```text
npx create-liveblocks-app@latest --init --framework react
```

3. ### Connect your Zustand store to Liveblocks

Create the Liveblocks client and use the `middleware` in your Zustand store setup. This will add a new state called `liveblocks` to your store, enabling you to interact with our Presence and Storage APIs.

#### store.ts

```ts
"use client";
import create from "zustand";
import { createClient } from "@liveblocks/client";
import { liveblocks } from "@liveblocks/zustand";
import type { WithLiveblocks } from "@liveblocks/zustand";
type State = {  // Your Zustand state type will be defined here};
const client = createClient({  publicApiKey: "pk_prod_xxxxxxxxxxxxxxxxxxxxxxxx",});
const useStore = create<WithLiveblocks<State>>()(  liveblocks(    (set) => ({      // Your state and actions will go here    }),    { client }  ));
export default useStore;
```

4. ### Join a Liveblocks room

Liveblocks uses the concept of rooms, separate virtual spaces where people collaborate. To create a realtime experience, multiple users must be connected to the same room.

#### App.tsx

```tsx
"use client";
import React, { useEffect } from "react";
import useStore from "./store";
import "./App.css";
const App = () => {  const {    liveblocks: { enterRoom, leaveRoom },  } = useStore();
     useEffect(() => {    enterRoom("room-id");    return () => {      leaveRoom("room-id");    };  }, [enterRoom, leaveRoom]);
     return <Room />;};
export default App;
```

5. ### Use the Liveblocks data from the store

Now that we’re connected to a room, we can start using the Liveblocks data from the Zustand store.

#### Room.tsx

```tsx
"use client";
import useStore from "./store";
export function Room() {  const others = useStore((state) => state.liveblocks.others);  const userCount = others.length;  return <div>There are {userCount} other user(s) online</div>;}
```

6. ### Next: set up authentication

By default, Liveblocks is configured to work without an authentication endpoint where everyone automatically has access to rooms. This approach is great for prototyping and marketing pages where setting up your own security isn’t always required. If you want to limit access to a room for certain users, you’ll need to set up an authentication endpoint to enable permissions.

[Set up authentication](/content/docs/authentication/index.html)

Congratulations! You now have set up the foundation to start building collaborative experiences for your Zustand store.

- [@liveblocks/zustand API Reference](/content/docs/api-reference/liveblocks-zustand/index.html)
- [Zustand guides](/content/docs/guides?technologies=zustand/index.html)
- [How to use Liveblocks Presence with Zustand](/content/docs/guides/how-to-use-liveblocks-presence-with-zustand/index.html)
- [How to use Liveblocks Storage with Zustand](/content/docs/guides/how-to-use-liveblocks-storage-with-zustand/index.html)

---

### Examples using Zustand

- \
\
**Collaborative To-do List** \
\
[Next.js, Vue, SvelteKit, Solid.js, JavaScript](/content/examples/collaborative-todo-list/zustand-todo-list/index.html)
- \
\
**Collaborative Whiteboard** \
\
[Next.js, Redux, Zustand](/content/examples/collaborative-whiteboard/zustand-whiteboard/index.html)
