Admin Node.js SDK 버전 10에는 다음과 같은 두 가지 중요한 변경사항이 있습니다.
Node.js 10 지원 중단(브레이킹 체인지)
SDK에서 모듈형 API 패턴 채택
이 가이드에서는 개발자가 기존 Node.js 앱을 Admin SDK의 이전 버전에서 v10으로 업그레이드하는 데 도움이 되는 안내와 정보를 제공합니다.
Node.js를 v12 이상으로 업데이트
Admin Node.js SDK v10 출시와 함께 Firebase는 Node.js 10 지원을 중단했습니다. 개발자는 Admin SDK를 사용할 때 Node.js 12 이상을 사용해야 합니다.
Admin Node.js SDK를 Cloud Functions for Firebase와 함께 사용하는 경우 Node.js 버전을 12 이상으로 업그레이드해야 합니다.
네임스페이스 대신 모듈 사용
처음부터 Admin Node.js SDK는 중첩된 네임스페이스 계층 구조로 구성된 안정적인 API를 제공했습니다. 따라서 다음과 같은 코드를 작성하는 데 익숙할 수 있습니다.
// Import the global admin namespaceimport*asadminfrom'firebase-admin';constapp:admin.app.App=admin.initializeApp();consttoken:string=awaitadmin.auth().createCustomToken('alice');constuser:admin.auth.UserRecord=awaitadmin.auth().getUser('bob');
Admin Node.js SDK는 v10부터 이름이 지정된 내보내기가 있는 여러 모듈 진입점을 제공합니다. 개발자는 전역 admin 네임스페이스를 사용하는 대신 새로운 진입점을 사용하여 SDK의 다양한 API에 액세스하는 것이 좋습니다.
새로운 모듈 진입점을 사용하면 위의 예시는 다음과 같이 작성됩니다.
TypeScript
// Import only what you needimport{initializeApp,App}from'firebase-admin/app';import{getAuth,UserRecord}from'firebase-admin/auth';constapp:App=initializeApp();consttoken:string=awaitgetAuth().createCustomToken('alice');constuser:UserRecord=getAuth().getUser('bob');
Node.js
// Import only what you needconst{initializeApp}=require('firebase-admin/app');const{getAuth}=require('firebase-admin/auth');constapp=initializeApp();consttoken=awaitgetAuth().createCustomToken('alice');constuser=getAuth().getUser('bob');
v10 모듈형 진입점 사용
위의 예시에서는 더 이상 전역 admin 네임스페이스를 가져오지 않습니다. 대신 여러 모듈 진입점에서 필요한 기호만 명시적으로 가져옵니다. 또한 TypeScript 개발자는 더 이상 admin.auth.UserRecord 및 admin.database.Reference와 같은 삼중 중첩 유형 식별자를 사용할 필요가 없습니다. 각 유형은 정확히 하나의 모듈에 속하므로 UserRecord 및 Reference와 같은 짧은 이름으로 가져오기만 하면 됩니다.
다음은 v10부터 SDK에서 사용할 수 있는 모든 모듈 진입점입니다.
firebase-admin/app
firebase-admin/auth
firebase-admin/database
firebase-admin/firestore
firebase-admin/instance-id
firebase-admin/machine-learning
firebase-admin/messaging
firebase-admin/project-management
firebase-admin/remote-config
firebase-admin/security-rules
firebase-admin/storage
다음 표는 각 기존 네임스페이스 함수에 대한 대체 가져오기 문법을 보여줍니다.
v9
v10
admin.initializeApp()
import { initializeApp } from 'firebase-admin/app'
initializeApp();
admin.app()
import { getApp } from 'firebase-admin/ap'
getApp();
admin.credential.cert()
import { cert } from 'firebase-admin/app'
cert();
admin.auth()
import { getAuth } from 'firebase-admin/auth'
getAuth();
admin.database()
import { getDatabase } from 'firebase-admin/database'
getDatabase();
admin.firestore()
import { getFirestore } from 'firebase-admin/firestore'
getFirestore();
admin.instanceId()
import { getInstanceId } from 'firebase-admin/instance-id'
getInstanceId();
admin.machineLearning()
import { getMachineLearning } from 'firebase-admin/machine-learning'
getMachineLearning();
admin.messaging()
import { getMessaging } from 'firebase-admin/messaging'
getMessaging()
admin.projectManagement()
import { getProjectManagement } from 'firebase-admin/project-management'
getProjectManagement();
admin.remoteConfig()
import { getRemoteConfig } from 'firebase-admin/remote-config'
getRemoteConfig();
admin.securityRules()
import { getSecurityRules } from 'firebase-admin/security-rules'
getSecurityRules()
admin.storage()
import { getStorage } from 'firebase-admin/storage'
getStorage();
앱에서 메서드 대신 내보낸 함수 사용
기존 API에서 App 객체는 app.auth() 및 app.database()와 같은 여러 메서드를 노출했습니다. 개발자는 이러한 메서드를 사용하지 않고 대신 위에서 설명된 것과 동일한 모듈 진입점을 사용하여 지정된 App 객체로 범위가 지정된 서비스 인스턴스를 가져오고 다른 앱별 작업을 수행하는 것이 좋습니다.
v9
v10
app.auth()
import { getAuth } from 'firebase-admin/auth';
getAuth(app);
app.database()
import { getDatabase } from 'firebase-admin/database';
getDatabase(app);
app.database(url)
import { getDatabaseWithUrl } from 'firebase-admin/database';
getDatabaseWithUrl(url, app);
app.firestore()
import { getFirestore } from 'firebase-admin/firestore'
getFirestore(app);
app.instanceId()
import { getInstanceId } from 'firebase-admin/instance-id'
getInstanceId(app);
app.machineLearning()
import { getMachineLearning } from 'firebase-admin/machine-learning'
getMachineLearning(app);
app.messaging()
import { getMessaging } from 'firebase-admin/messaging'
getMessaging(app);
app.projectManagement()
import { getProjectManagement } from 'firebase-admin/project-management'
getProjectManagement(app);
app.remoteConfig()
import { getRemoteConfig } from 'firebase-admin/remote-config'
getRemoteConfig(app);
app.securityRules()
import { getSecurityRules } from 'firebase-admin/security-rules'
getSecurityRules(app);
app.storage()
import { getStorage } from 'firebase-admin/storage'
getStorage(app);
app.delete()
import { deleteApp } from 'firebase-admin/app';
deleteApp(app);
ES 모듈 지원
Node.js 12 이상은 ES 모듈을 실험적으로 지원하므로 TypeScript를 사용하지 않는 개발자도 자신의 코드에 export 및 import 키워드를 사용할 수 있습니다. Admin Node.js SDK는 v10부터 ES 모듈도 지원하므로 일반 Node.js에서 ES 모듈을 구현하는 개발자는 import 구문을 사용하여 SDK를 가져올 수 있습니다.
ES 모듈을 Admin SDK와 함께 사용하려면 먼저 Node.js 런타임에 ESM 지원을 사용 설정해야 합니다. 보통 package.json 파일에 "type":
"module" 필드를 추가하여 사용 설정할 수 있습니다. 그런 다음 애플리케이션 코드를 다음과 같이 작성할 수 있습니다.
// With {type: module} in the package.json...// Import only what you needimport{initializeApp}from'firebase-admin/app';import{getAuth}from'firebase-admin/auth';constapp=initializeApp();consttoken=awaitgetAuth().createCustomToken('alice');constuser=getAuth().getUser('bob');
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["\u003cbr /\u003e\n\nVersion 10 of the Admin Node.js SDK introduces two important changes:\n\n- Support for Node.js 10 is discontinued (this is a **breaking change**)\n- The SDK has adopted a modular API pattern\n\nThis guide provides instructions and information to help developers upgrade\nexisting Node.js apps from earlier versions of the Admin SDK to v10.\n\nUpdate Node.js to v12 or higher\n\nWith the Admin Node.js SDK v10 release, Firebase has discontinued support for\nNode.js 10. Developers must use Node.js 12 or higher when using the Admin SDK.\nIf you're using the Admin Node.js SDK together with Cloud Functions for Firebase,\nmake sure that you have\n[upgraded your Node.js version](/docs/functions/manage-functions#upgrade-node10)\nto 12 or higher.\n\nUse modules instead of namespaces\n\nSince its inception, the Admin Node.js SDK has offered a stable API structured\nas a nested namespace hierarchy. As a result, you might have become familiar\nwith writing code that looks like this: \n\n // Import the global admin namespace\n import * as admin from 'firebase-admin';\n\n const app: admin.app.App = admin.initializeApp();\n\n const token: string = await admin.auth().createCustomToken('alice');\n\n const user: admin.auth.UserRecord = await admin.auth().getUser('bob');\n\nStarting from v10, the Admin Node.js SDK offers multiple module entry points\nwith named exports. We recommend developers to use these new entry points to\naccess the various APIs of the SDK, as opposed to using the global `admin`\nnamespace.\n\nHere's what the above example would look like with the new module\nentry points: \n\nTypeScript \n\n // Import only what you need\n import { initializeApp, App } from 'firebase-admin/app';\n import { getAuth, UserRecord } from 'firebase-admin/auth';\n\n const app: App = initializeApp();\n\n const token: string = await getAuth().createCustomToken('alice');\n\n const user: UserRecord = getAuth().getUser('bob');\n\nNode.js \n\n // Import only what you need\n const { initializeApp } = require('firebase-admin/app');\n const { getAuth } = require('firebase-admin/auth');\n\n const app = initializeApp();\n\n const token = await getAuth().createCustomToken('alice');\n\n const user = getAuth().getUser('bob');\n\nUsing v10 modular entry points\n\nNote that, in the examples above, you are no longer importing a global `admin`\nnamespace. Instead, you explicitly import only the symbols you need from several\nmodule entry points. Also, TypeScript developers no longer have to use triple-\nnested type identifiers like `admin.auth.UserRecord` and\n`admin.database.Reference`. Since each type belongs to exactly one module, you\ncan just import them by their short names like `UserRecord` and `Reference`.\n\nHere are all the module entry points available in the SDK as of v10:\n\n- firebase-admin/app\n- firebase-admin/auth\n- firebase-admin/database\n- firebase-admin/firestore\n- firebase-admin/instance-id\n- firebase-admin/machine-learning\n- firebase-admin/messaging\n- firebase-admin/project-management\n- firebase-admin/remote-config\n- firebase-admin/security-rules\n- firebase-admin/storage\n\nThe following table shows the replacement import syntax for each of the legacy\nnamespace functions:\n\n| **v9** | **v10** |\n|-----------------------------|------------------------------------------------------------------------------------------------------|\n| `admin.initializeApp()` | `import { initializeApp } from 'firebase-admin/app'` `initializeApp();` |\n| `admin.app()` | `import { getApp } from 'firebase-admin/ap'` `getApp();` |\n| `admin.credential.cert()` | `import { cert } from 'firebase-admin/app'` `cert();` |\n| `admin.auth()` | `import { getAuth } from 'firebase-admin/auth'` `getAuth();` |\n| `admin.database()` | `import { getDatabase } from 'firebase-admin/database'` `getDatabase();` |\n| `admin.firestore()` | `import { getFirestore } from 'firebase-admin/firestore'` `getFirestore();` |\n| `admin.instanceId()` | `import { getInstanceId } from 'firebase-admin/instance-id'` `getInstanceId();` |\n| `admin.machineLearning()` | `import { getMachineLearning } from 'firebase-admin/machine-learning'` `getMachineLearning();` |\n| `admin.messaging()` | `import { getMessaging } from 'firebase-admin/messaging'` `getMessaging()` |\n| `admin.projectManagement()` | `import { getProjectManagement } from 'firebase-admin/project-management'` `getProjectManagement();` |\n| `admin.remoteConfig()` | `import { getRemoteConfig } from 'firebase-admin/remote-config'` `getRemoteConfig();` |\n| `admin.securityRules()` | `import { getSecurityRules } from 'firebase-admin/security-rules'` `getSecurityRules()` |\n| `admin.storage()` | `import { getStorage } from 'firebase-admin/storage'` `getStorage();` |\n\nUse exported functions instead of methods on App\n\nIn the legacy API, the `App` object exposed a number of methods like\n`app.auth()` and `app.database()`. We recommend developers to avoid using these\nmethods, and instead use the same module entry points described above to obtain\nservice instances scoped to a given `App` object, and perform other app-specific\ntasks.\n\n| **v9** | **v10** |\n|---------------------------|---------------------------------------------------------------------------------------------------------|\n| `app.auth()` | `import { getAuth } from 'firebase-admin/auth';` `getAuth(app);` |\n| `app.database()` | `import { getDatabase } from 'firebase-admin/database';` `getDatabase(app);` |\n| `app.database(url)` | `import { getDatabaseWithUrl } from 'firebase-admin/database';` `getDatabaseWithUrl(url, app);` |\n| `app.firestore()` | `import { getFirestore } from 'firebase-admin/firestore'` `getFirestore(app);` |\n| `app.instanceId()` | `import { getInstanceId } from 'firebase-admin/instance-id'` `getInstanceId(app);` |\n| `app.machineLearning()` | `import { getMachineLearning } from 'firebase-admin/machine-learning'` `getMachineLearning(app);` |\n| `app.messaging()` | `import { getMessaging } from 'firebase-admin/messaging'` `getMessaging(app);` |\n| `app.projectManagement()` | `import { getProjectManagement } from 'firebase-admin/project-management'` `getProjectManagement(app);` |\n| `app.remoteConfig()` | `import { getRemoteConfig } from 'firebase-admin/remote-config'` `getRemoteConfig(app);` |\n| `app.securityRules()` | `import { getSecurityRules } from 'firebase-admin/security-rules'` `getSecurityRules(app);` |\n| `app.storage()` | `import { getStorage } from 'firebase-admin/storage'` `getStorage(app);` |\n| `app.delete()` | `import { deleteApp } from 'firebase-admin/app';` `deleteApp(app);` |\n\nES modules support\n\nNode.js 12 and above come with experimental support for ES modules, enabling\neven non-TypeScript developers to use the `export` and `import` keywords in\ntheir code. Starting from the v10 release, the Admin Node.js SDK also provides\nES modules support, so that developers implementing ES modules on plain Node.js\ncan import the SDK using `import` syntax.\n\nTo use ES modules with the Admin SDK, first make sure you have enabled ESM\nsupport for your Node.js runtime. This is usually done by adding a `\"type\":\n\"module\"` field to your `package.json` file. Then you can write application code\nthat looks like this: \n\n // With {type: module} in the package.json...\n\n // Import only what you need\n import { initializeApp } from 'firebase-admin/app';\n import { getAuth } from 'firebase-admin/auth';\n\n const app = initializeApp();\n\n const token = await getAuth().createCustomToken('alice');\n\n const user = getAuth().getUser('bob');"]]