> For the complete documentation index, see [llms.txt](https://dashboard-hero.gitbook.io/dashboard-hero/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dashboard-hero.gitbook.io/dashboard-hero/backend/firebase-cloud-functions.md).

# Firebase cloud functions

Put very simply, Firebase cloud functions are pieces of javascript code that reside on the server and run each time a request from the client is made.

Each such request has meta information - **context** - from which we can extract authentication information, such as the user id. Each request also has a **data** object, to which we can pass information from the client.

Here is how one can call a cloud function from the client:

```javascript
firebase.app().functions().httpsCallable('inviteUser')
.inviteUser(
    { email: email, fullname: 'John Doe', userId: generateUUID() }
);
```

And here is how the function responding to this user call looks like:

```python
exports.inviteUser = functions
	.https.onCall(async (data, context) => {
		let company = await getCompanyNameFromUserId( context.auth.uid )
		const { fullname, email, userId } = data;
	  // do the wiring with the vars extracted from data
	  // create user account, add user to company, send verification email
		...
		return ...
		);
		
	});
```
