Skip to main content

User Actions

User server actions are functions which interact with the user data in the database. These functions are used to perform operations on the user data, such as creating, updating, and deleting user data.

Functions

getUserProfile()

Gets the user profile document by its ID.

Example usage:

import { getUserProfile } from "@/app/_db/server-actions/user";
...
const [userInfo, setUserInfo] = useState(null);

useEffect(() => {
try {
getUserProfile().then((data) => {
setUserInfo(data);
});
} catch (error) {
console.error("Error fetching user data:", error);
}
}, []);
...

updateUserProfile()

Updates the user profile document. This function is intended to be used with an HTML form data object. This will often be called with the react hook useFormState.

Example usage:

import { updateUserProfile } from "@/app/_db/server-actions/user";
...
const [formState, setFormState] = useFormState(updateUserProfile, userInfo);
...