Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
Firebase Realtime Database — это облачная база данных. Данные хранятся в формате JSON и синхронизируются в режиме реального времени с каждым подключенным клиентом. При создании кроссплатформенных приложений с использованием наших платформ Android, Apple и JavaScript SDK все ваши клиенты используют один экземпляр Realtime Database и автоматически получают обновления с самыми актуальными данными.
Перейдите в раздел Realtime Databaseконсоли Firebase . Вам будет предложено выбрать существующий проект Firebase. Следуйте инструкциям по созданию базы данных.
Выберите начальный режим для Firebase Security Rules :
Тестовый режим
Подходит для начала работы с библиотеками мобильных и веб-клиентов, но позволяет любому читать и перезаписывать ваши данные. После тестирования обязательно ознакомьтесь с разделом «Понимание правил базы данных Firebase Realtime» .
Чтобы начать работу с веб-, Apple или Android SDK, выберите тестовый режим.
Заблокированный режим
Запрещает все операции чтения и записи с мобильных и веб-клиентов. Ваши аутентифицированные серверы приложений по-прежнему смогут получать доступ к вашей базе данных.
Выберите место для базы данных.
В зависимости от местоположения базы данных URL-адрес новой базы данных будет иметь одну из следующих форм:
DATABASE_NAME .firebaseio.com (для баз данных в us-central1 )
DATABASE_NAME . REGION .firebasedatabase.app (для баз данных во всех остальных местах)
Нажмите Готово .
При включении Realtime Database также включается API в Cloud API Manager .
Настройка Realtime Database Security Rules
Realtime Database предоставляет язык декларативных правил, который позволяет вам определять, как должны быть структурированы ваши данные, как они должны быть индексированы и когда ваши данные могут быть прочитаны и записаны.
Добавьте Realtime Database JS SDK и инициализируйте Realtime Database
При инициализации JavaScript SDK необходимо указать URL-адрес вашей Realtime Database .
URL-адрес вашей Realtime Database можно найти в разделе Realtime Databaseконсоли Firebase . В зависимости от расположения базы данных , URL-адрес базы данных может иметь один из следующих форматов:
https:// DATABASE_NAME .firebaseio.com (для баз данных в us-central1 )
https:// DATABASE_NAME . REGION .firebasedatabase.app (для баз данных во всех остальных местах)
Инициализируйте SDK, используя следующий фрагмент кода:
[null,null,["Последнее обновление: 2025-08-08 UTC."],[],[],null,["\u003cbr /\u003e\n\nThe Firebase Realtime Database is a cloud-hosted database. Data is stored as\nJSON and synchronized in realtime to every connected client. When you build\ncross-platform apps with our Android, Apple platforms, and JavaScript SDKs, all of your\nclients share one Realtime Database instance and automatically receive\nupdates with the newest data.\n\nPrerequisites\n\nIf you haven't already, [install the Firebase JS SDK and initialize Firebase](/docs/web/setup#add-sdk-and-initialize).\n\nCreate a Database\n\n1. Navigate to the **Realtime Database** section of the\n [Firebase console](https://console.firebase.google.com/project/_/database).\n You'll be prompted to select an existing Firebase project.\n Follow the database creation workflow.\n\n2. Select a starting mode for your Firebase Security Rules:\n\n Test mode\n\n : Good for getting started with the mobile and web client libraries,\n but allows anyone to read and overwrite your data. After testing, **make\n sure to review the [Understand Firebase Realtime Database Rules](/docs/database/security)\n section.**\n\n :\n | **Note:** If you create a database in Test mode and make no changes to the default world-readable and world-writeable Rules within a trial period, you will be alerted by email, then your database rules will deny all requests. Note the expiration date during the Firebase console setup flow.\n\n : To get started with the web, Apple, or Android SDK, select testmode.\n\n Locked mode\n\n : Denies all reads and writes from mobile and web clients.\n Your authenticated application servers can still access your database.\n\n3. Choose a location for the database.\n\n Depending on the\n [location of the database](/docs/projects/locations#rtdb-locations), the\n URL for the new database will be in one of the following forms:\n - \u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e`.firebaseio.com` (for\n databases in `us-central1`)\n\n - \u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e`.`\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e`.firebasedatabase.app`\n (for databases in all other locations)\n\n4. Click **Done**.\n\nWhen you enable Realtime Database, it also enables the API in the\n[Cloud API Manager](https://console.cloud.google.com/projectselector/apis/api/firebasedatabase.googleapis.com/overview).\n\nConfigure Realtime Database Security Rules\n\nThe Realtime Database provides a declarative rules language that allows you to\ndefine how your data should be structured, how it should be indexed, and when\nyour data can be read from and written to.\n| **Note:** By default, read and write access to your database is restricted so only authenticated users can read or write data. To get started without setting up [Authentication](/docs/auth), you can [configure your rules for public access](/docs/rules/basics#default_rules_locked_mode). This does make your database open to anyone, even people not using your app, so be sure to restrict your database again when you set up authentication.\n\nAdd the Realtime Database JS SDK and initialize Realtime Database\n\nYou must specify your Realtime Database URL when initializing the JavaScript SDK.\n\nYou can find your Realtime Database URL in the *Realtime Database* section of the\n[Firebase console](//console.firebase.google.com/). Depending on the\n[location of the database](/docs/projects/locations#rtdb-locations),\nthe database URL will be in one of the following forms:\n\n- `https://`\u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e`.firebaseio.com` (for databases in `us-central1`)\n- `https://`\u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e`.`\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e`.firebasedatabase.app` (for databases in all other locations)\n\nInitialize the SDK using the following code snippet: \n\nWeb\n\n\n| [Learn more](/docs/web/learn-more#modular-version) about the tree-shakeable modular web API and [upgrade](/docs/web/modular-upgrade) from the namespaced API.\n\n\u003cbr /\u003e\n\n```python\nimport { initializeApp } from \"firebase/app\";\nimport { getDatabase } from \"firebase/database\";\n\n// TODO: Replace the following with your app's Firebase project configuration\n// See: https://firebase.google.com/docs/web/learn-more#config-object\nconst firebaseConfig = {\n // ...\n // The value of `databaseURL` depends on the location of the database\n databaseURL: \"https://\u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e.firebaseio.com\",\n};\n\n// Initialize Firebase\nconst app = initializeApp(firebaseConfig);\n\n\n// Initialize Realtime Database and get a reference to the service\nconst database = getDatabase(app);\n```\n\nWeb\n\n\n| [Learn more](/docs/web/learn-more#modular-version) about the tree-shakeable modular web API and [upgrade](/docs/web/modular-upgrade) from the namespaced API.\n\n\u003cbr /\u003e\n\n```python\nimport firebase from \"firebase/app\";\nimport \"firebase/compat/database\";\n\n// TODO: Replace the following with your app's Firebase project configuration\n// See: https://firebase.google.com/docs/web/learn-more#config-object\nconst firebaseConfig = {\n // ...\n // The value of `databaseURL` depends on the location of the database\n databaseURL: \"https://\u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e.firebaseio.com\",\n};\n\n// Initialize Firebase\nfirebase.initializeApp(firebaseConfig);\n\n\n// Initialize Realtime Database and get a reference to the service\nconst database = firebase.database();\n```\n\nYou're ready to start using the Firebase Realtime Database!\n\nNext Steps\n\n- Learn how to [structure data](/docs/database/web/structure-data) for Realtime Database.\n\n- [Scale your data across multiple database\n instances](/docs/database/usage/sharding).\n\n- [Read and write data.](/docs/database/web/read-and-write)\n\n- [View your database in the\n Firebase console.](//console.firebase.google.com/project/_/database/data)\n\n- Prepare to launch your app:\n\n - Enable [App Check](/docs/app-check/web) to help ensure that only your\n apps can access your databases.\n\n - Set up [budget\n alerts](/docs/projects/billing/avoid-surprise-bills#set-up-budget-alert-emails)\n for your project in the Google Cloud console.\n\n - Monitor the [*Usage and billing*\n dashboard](//console.firebase.google.com/project/_/usage)\n in the Firebase console to get an overall picture of your project's\n usage across multiple Firebase services.\n You can also visit the [Realtime Database *Usage*\n dashboard](//console.firebase.google.com/project/_/database/usage) for more\n detailed usage information.\n\n - Review the [Firebase launch checklist](/support/guides/launch-checklist)."]]