# Firebase Cloud Functions

Use when calling callable functions (httpsCallable), passing data to server-side logic...

- Repository: https://github.com/evanca/flutter-ai-rules (668 stars)
- Category: Testing
- License: MIT
- Last updated: 2026-10-30
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add evanca/flutter-ai-rules --skill firebase-cloud-functions -g -a claude-code -y`
Codex: `npx skills add evanca/flutter-ai-rules --skill firebase-cloud-functions -g -a codex -y`
Cursor: `npx skills add evanca/flutter-ai-rules --skill firebase-cloud-functions -g -a cursor -y`
Gemini CLI: `npx skills add evanca/flutter-ai-rules --skill firebase-cloud-functions -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add evanca/flutter-ai-rules`

## Description

Use when calling callable functions (httpsCallable), passing data to server-side logic, handling function errors/timeouts, configuring regions, or testing with the Emulator Suite.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Firebase Cloud Functions Skill

This skill defines how to correctly call Firebase Cloud Functions from Flutter applications.

## When to Use

Use this skill when:

* Implementing callable Cloud Functions in a Flutter project.
* Passing structured data to server-side functions and processing results.
* Handling errors, timeouts, and retries for function calls.
* Configuring region-specific function deployments.
* Testing Cloud Functions locally with the Firebase Emulator Suite.

---

## 1. Setup and Configuration

```
flutter pub add cloud_functions
```

```dart
import 'package:cloud_functions/cloud_functions.dart';

// After Firebase.initializeApp():
final functions = FirebaseFunctions.instance;
```

- Initialize Firebase before using any Cloud Functions features.
- For region-specific deployments, specify the region:

```dart
final functions = FirebaseFunctions.instanceFor(region: 'europe-west1');
```

- Deploy callable functions to Firebase **before** attempting to call them from the Flutter app.
- Consider implementing **App Check** to prevent abuse of Cloud Functions.

---

## 2. Calling Functions

Use `httpsCallable` to reference a function, then `call` to invoke it:

```dart
final result = await FirebaseFunctions.instance
  .httpsCallable('functionName')
  .call(data);
```

- Pass data as a `Map`, it is automatically serialized to JSON:

```dart
final result = await FirebaseFunctions.instance
  .httpsCallable('addMessage')
  .call({
    "text": messageText,
    "push": true,
  });
```

- Access the result via the `data` property, it is automatically deserialized from JSON:

```dart
final responseData = result.data;
// Cast to expected type if needed:
final message = result.data as Map<String, dynamic>;
final status = message['status'] as String;
```

- **Do not** pass authentication tokens in function parameters, they are automatically included by the SDK.
- Keep function names consistent between client code and server-side implementations.

---

The rest: https://github.com/evanca/flutter-ai-rules/blob/HEAD/skills/firebase-cloud-functions/SKILL.md
