> ## Documentation Index
> Fetch the complete documentation index at: https://docs.duca.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Meteor Subscribe with useTracker()

> Sample code that uses useTracker in order to subscribe and read the pointers of a published colletion on Meteor.

# Meteor React

Check out the [Meteor React](https://www.meteor.com/tutorials/react/creating-an-app) tutorial.

# Publishing the collection

```javascript theme={null}
Meteor.publish('users', function() {
    return Users.find();
});
```

In order to access a collection on the client side, you need to publish it on the server side. This is done by adding a publication to the server/main.js file. In this case, we are publishing the Users collection.

# Reading the collection

```javascript theme={null}
import React from 'react';
import { useTracker } from 'meteor/react-meteor-data';

export const UsersComponent = () => {
  const { users, isLoading } = useTracker(() => {
    const noDataAvailable = { users: [] };

    const handler = Meteor.subscribe('users');

    if (!handler.ready()) {
      return { ...noDataAvailable, isLoading: true };
    }

    const users = Users.find().fetch();

    return { users };
  });

  return (
    <div>
      {isLoading ? (
        <p>Loading...</p>
      ) : (
        <ul>
          {users.map((user, index) => (
            <li key={user._id}>{user.name}</li>
          ))}
        </ul>
      )}
    </div>
  );
};

```
