0.0.5 • Published 4 years ago
crespo v0.0.5
crespo (name TBD)
What I want to achieve
$ crespo init todo-list # initialize project
...created project "todo-list" on backend
...installed npm packages
...updated '.env' with your tokens
Go ahead and add some collections to your project:
https://crespo.com/manage/<project-id>
// in a React component
import { useAuthHook, login, logout } from 'crespo'
export default () => {
const [todos, { mutate, auth }] = useAuthHook({
resource: 'todos', // db collection
query: 'all', // retrieve all To Do items
pagination: { max: 10, page: 1 },
})
if (auth == false) {
// user not logged in
return <button onClick={login}>Login</button>
}
return (
<>
<button onClick={logout}>Logout</button>
<ul>{todos.map(renderArticle)}</ul>
</>
)
}