https://github.com/quavedev/logged-user
https://github.com/quavedev/logged-user
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/quavedev/logged-user
- Owner: quavedev
- Created: 2021-02-08T11:57:33.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-10-17T02:22:29.000Z (almost 5 years ago)
- Last Synced: 2025-02-27T21:45:05.278Z (over 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 15
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# quave:logged-user
This is a meteor package that creates a context for the logged user. This context contains the `loggedUser` and `loadingLoggedUser` fields and the functions `refetchLoggedUser` and `logout`.
`loggedUser`: the logged user on the meteor accounts.
`loadingLoggedUser`: TRUE when the user is logging in or the `refetchLoggedUser` is called.
`refetchLoggedUser`: a function to refetch the logged user when you need to update its data on the client side.
`logout`: a function to logout the user.
## Dependencies
This package has these `npm` depencies. They're not enforced because this could
cause [some problems](https://guide.meteor.com/writing-atmosphere-packages.html#peer-npm-dependencies)
.
* `react`
* `@apollo/react-hooks`
* `graphql-tag`
## Installation
```bash
meteor add quave:logged-user
```
## Example
```javascript
//home.js
import { useLoggedUser } from 'meteor/quave:logged-user/useLoggedUser';
const Home = () => {
const { loggedUser } = useLoggedUser();
if (loggedUser) {
return "You are logged in!!!";
}
return "Sorry, you need to log in"
}
//app.js
import { LoggedUserProvider } from 'meteor/quave:use-logged-user/LoggedUserProvider';
// Use the Form component
```