This is a sample app for the preview version of the Firebase DataConnect. This service is currently in Private Preview at no cost for a limited time. Sign up for the program at Firebase Data Connect. This quickstart will not work if you don't have access to the preview.
Follow these steps to get up and running with Firebase Data Connect. For more detailed instructions, check out the official documentation.
- Open Firebase Data Connect in your project in Firebase Console and select Get Started.
- Create a new Data Connect service and a Cloud SQL instance. Ensure the Blaze plan is active. Pricing details can be found at Firebase Pricing.
- Select your server region, if you wish to use vector search, make sure to select
us-central1region. - Allow some time for the Cloud SQL instance to be provisioned. After it's provisioned, the instance can be managed in the Cloud Console.
Ensure the Firebase CLI is installed and up to date:
npm install -g firebase-toolsThis repository contains the quickstart to get started with the functionalities of Data Connect.
- Clone this repository to your local machine.
- Initialize your Firebase project with
firebase init dataconnect. Overwrite only dataconnect.yaml when prompted, do not overwrite any other dataconnect files. (Optional): If you intend on using other Firebase features, runfirebase initinstead, and select both DataConnect options as well as any feature you intend to use. - Replace variables in
.envwith your project-specific values. - Allow domains for Firebase Auth in your project console (e.g. http://127.0.0.1).
The VSCode Firebase Extension allows you to generate Firebase Data Connect SDK code, run queries/mutations, and deploy Firebase Data Connect with a click. Alternatively, see below for CLI commands.
- Install VS Code.
- Download the Firebase extension and install it.
- Open this quickstart in VS code, and in the left pane of the Firebase extension, and log in with your Firebase account.
(Optional): If your Firebase project was not initialized in the last section, you can click
Run firebase initand selectData Connectto initialize. - Click on deploy to deploy your schema to your cloud SQL instance. Or run
firebase deploy --only dataconnect(this will also activate vectors search if it's enabled in the schema). - Running the VSCode extension should automatically start the DataConnect emulators. If you see an emulators error, try running
firebase emulators:start dataconnectmanually.
Now you should be able to deploy your schema, run mutations/queries, generate SDK code, and view your application locally.
- Run
1_movie_insert.gql,2_actor_insert.gql,3_movie_actor_insert.gql, and4_user_favorites_review_insert.gqlfiles in the./dataconnectdirectory in order using the VS code extension,
cdinto the src folder, and runnpm run devto start the localhost web app. (Optional): To use the Firebase Auth emulator, runfirebase emulators:startand uncomment theconnectAuthEmulatorfunction inapp/src/lib/firebase.ts.
© Google, 2024. Licensed under an Apache-2 license.