{"id":13599034,"url":"https://github.com/jthegedus/svelte-adapter-firebase","last_synced_at":"2025-04-04T18:09:33.625Z","repository":{"id":37421482,"uuid":"326604100","full_name":"jthegedus/svelte-adapter-firebase","owner":"jthegedus","description":"SvelteKit adapter for Firebase Hosting rewrites to Cloud Functions for a Svelte SSR experience","archived":false,"fork":false,"pushed_at":"2023-06-18T15:55:53.000Z","size":1762,"stargazers_count":284,"open_issues_count":18,"forks_count":34,"subscribers_count":21,"default_branch":"main","last_synced_at":"2024-10-17T20:04:31.367Z","etag":null,"topics":["cloud-functions","cloud-run","firebase","serverless","ssr","svelte","svelte-adapter","sveltekit","sveltekit-adapter"],"latest_commit_sha":null,"homepage":"https://github.com/jthegedus/svelte-adapter-firebase","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jthegedus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":["jthegedus"]}},"created_at":"2021-01-04T07:32:34.000Z","updated_at":"2024-09-15T22:29:00.000Z","dependencies_parsed_at":"2024-01-16T23:25:53.699Z","dependency_job_id":"3016e60a-9623-4071-b3c1-370e515063f9","html_url":"https://github.com/jthegedus/svelte-adapter-firebase","commit_stats":{"total_commits":186,"total_committers":15,"mean_commits":12.4,"dds":"0.33870967741935487","last_synced_commit":"d5e9691b131473c5277a97c09d7563d618a33f5b"},"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthegedus%2Fsvelte-adapter-firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthegedus%2Fsvelte-adapter-firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthegedus%2Fsvelte-adapter-firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jthegedus%2Fsvelte-adapter-firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jthegedus","download_url":"https://codeload.github.com/jthegedus/svelte-adapter-firebase/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226215,"owners_count":20904465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloud-functions","cloud-run","firebase","serverless","ssr","svelte","svelte-adapter","sveltekit","sveltekit-adapter"],"created_at":"2024-08-01T17:00:59.106Z","updated_at":"2025-04-04T18:09:33.608Z","avatar_url":"https://github.com/jthegedus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/jthegedus"],"categories":["Adapters"],"sub_categories":["The _How To's?_"],"readme":"\u003cdiv align=\"center\"\u003e\n\n| :warning: WARNING: Firebase have introduced first-party support for [Web Frameworks](https://firebase.google.com/docs/hosting/frameworks/frameworks-overview). [SvelteKit support is experimental](https://github.com/FirebaseExtended/firebase-framework-tools). This adapter may be deprecated in future as it cannot support the same level of integration as the official team and tooling. Use at your own risk. |\n| ---------------------------------------------------------------------------------------------------- |\n\n![SvelteKit adapter Firebase social preview](assets/github-preview-svelte-adapter-firebase.png)\n\n# svelte-adapter-firebase\n\n[![GitHub Release](https://img.shields.io/github/release/jthegedus/svelte-adapter-firebase.svg?color=green)](https://github.com/jthegedus/svelte-adapter-firebase/releases)\n[![npm](https://img.shields.io/npm/v/svelte-adapter-firebase?color=green)](https://www.npmjs.com/package/svelte-adapter-firebase)\n[![Tests](https://github.com/jthegedus/svelte-adapter-firebase/actions/workflows/test.yaml/badge.svg)](https://github.com/jthegedus/svelte-adapter-firebase/actions/workflows/test.yaml)\n[![CodeQL](https://github.com/jthegedus/svelte-adapter-firebase/actions/workflows/codeql-analysis.yaml/badge.svg)](https://github.com/jthegedus/svelte-adapter-firebase/actions/workflows/codeql-analysis.yaml)\n\n[Firebase](https://firebase.google.com/) adapter for\n[SvelteKit](https://github.com/sveltejs/kit).\n\nUtilise the Firebase Hosting CDN with dynamic content served by SvelteKit on\nCloud Functions!\n\n:heavy_check_mark: SSR on\n[Cloud Functions](https://firebase.google.com/docs/hosting/functions)\u003c/br\u003e\n:heavy_check_mark: Integrates with existing Cloud Functions!\u003c/br\u003e\n:heavy_check_mark: Local production testing with\n[Firebase Emulator](https://firebase.google.com/docs/emulator-suite)\u003c/br\u003e\n:heavy_check_mark: Mitigate cold-starts with\n[minInstances](https://firebase.google.com/docs/functions/manage-functions#min-max-instances)\u003c/br\u003e\n:heavy_check_mark:\n[Multiple Hosting Sites](https://firebase.google.com/docs/hosting/multisites#add_additional_sites)\u003c/br\u003e\n\n\u003c/div\u003e\n\n## Contents\n\n- [Contents](#contents)\n- [Setup](#setup)\n  - [Beta Adapter Version Compatibility](#beta-adapter-version-compatibility)\n- [Configuration Overview](#configuration-overview)\n- [Details](#details)\n  - [`firebase.json` Configurations](#firebasejson-configurations)\n  - [Adapter Configurations](#adapter-configurations)\n- [How it works](#how-it-works)\n- [Firebase Emulator local Testing](#firebase-emulator-local-testing)\n- [Deployment](#deployment)\n- [Caveats](#caveats)\n- [Non-goals](#non-goals)\n- [FAQ](#faq)\n- [Contributing](#contributing)\n  - [external contributions](#external-contributions)\n\n## Setup\n\nThe adapter reads `firebase.json` to determine output dirs for Server scripts \u0026\nStatic assets, without this file the adapter cannot know how your Firebase app\nis configured. Hosting \u0026 Cloud Functions are required.\n\nIn your standard SvelteKit project:\n\n- `npm install --save-dev svelte-adapter-firebase`\n- add adapter to `svelte.config.js`:\n\n```diff\n+import firebase from \"svelte-adapter-firebase\";\n\n/** @type {import('@sveltejs/kit').Config} */\nexport default {\n  kit: {\n+   adapter: firebase(),\n  },\n};\n```\n\n- Setup `firebase.json` with `firebase init`.\n- `npm run build`. **Read and repeat, the output is meant as a guide. IE: after\n  your first build, you need to manually add the produced Cloud Function in\n  `index.js`**\n\n\u003c!-- TODO: on 1.0.0 release, delete this section --\u003e\n\n### Beta Adapter Version Compatibility\n\nThis adapter has not been tested beyond the versions listed below, use at your own risk:\n\n| Adapter Version | SvelteKit Version    |\n| --------------- | -------------------- |\n| `0.15.0`        | `1.1.1`              |\n| `0.14.5`        | `1.0.0-next.587`     |\n| `0.14.4`        | `1.0.0-next.443`     |\n| `0.14.3`        | `1.0.0-next.443`     |\n| `0.14.2`        | `1.0.0-next.405`     |\n| `0.14.0`        | `1.0.0-next.330`     |\n| `0.13.1`        | `1.0.0-next.180`     |\n| `0.13.0`        | `1.0.0-next.168`     |\n| `0.12.x`        | `1.0.0-next.165`     |\n| `0.11.x`        | `1.0.0-next.155`     |\n| `NA`            | `1.0.0-next.152-154` |\n| `0.10.x`        | `1.0.0-next.132`     |\n| `0.9.1`         | `1.0.0-next.122`     |\n| `0.9.0`         | `1.0.0-next.120`     |\n| `0.8.x`         | `1.0.0-next.111`     |\n| `NA`            | `1.0.0-next.109-110` |\n| `0.7.x`         | `1.0.0-next.107`     |\n| `0.6.x`         | `1.0.0-next.103`     |\n| `0.5.x`         | `1.0.0-next.54`      |\n| `0.4.x`         | `1.0.0-next.46`      |\n| `0.3.x`         | `1.0.0-next.27`      |\n\n**Note**: only the versions listed have been tested together, if others happen\nto work, it is just coincidence. This is beta software after all.\n\n\u003c!-- END --\u003e\n\n## Configuration Overview\n\nAdapter options:\n\n- `esbuildBuildOptions`\n  - function to return an `esbuild.BuildOptions` object\n  - default: see `defaultOptions` object in [`src/index.js`](./src/index.js)\n- `firebaseJsonPath`\n  - path to your `firebase.json` file, **relative** from where `svelte build` is\n    called\n  - default: `./firebase.json`\n- `target`\n  - required when `firebase.json:hosting` is an array (contains many site\n    configurations)\n  - default: `undefined`\n- `sourceRewriteMatch`\n  - used to lookup the rewrite config to determine whether to output SSR code\n    for Cloud Functions. See\n    [Firebase Rewrite configuration docs](https://firebase.google.com/docs/hosting/full-config#rewrite-functions).\n  - default: `**`\n\nAdapter output:\n\n- static assets (images, CSS, Client-side JavaScript) of your SvelteKit app\n  output to the directory defined by `firebase.json:hosting.public`\n- server assets (SSR JavaScript) output alongside your Cloud Functions defined\n  by `firebase.json:functions.source`\n\n## Details\n\n[Setup](#setup) outlines the steps most commonly used with a single SvelteKit\napp. Here we go into the details of each configuration and how it interacts with\nthe `firebase.json` config.\n\nThe 3 step process is:\n\n1. select Hosting config from `firebase.json`. If more than one site present in\n   config, match `svelte.config.js:target` field with either\n   `firebase.json:hosting[].site` or `.target` fields.\n2. output static assets to the directory in the `public` field\n3. identify the rewrite rule for SSR to determine Cloud Function output. The\n   rewrite rule is determined by a lookup of the `rewrites.source` against\n   `sourceRewriteMatch`\n\n### `firebase.json` Configurations\n\nDue to the relaxed rules of `firebase.json` we can have many valid configs. At a\nminimum, one or more Hosting sites is required with an associated Functions\nconfig if a Cloud Function rewrite is used. These are the combintations:\n\n\u003cdetails\u003e\n\u003csummary\u003esingle Hosting site with Cloud Function rewrite\u003c/summary\u003e\n\n```json\n{\n  \"hosting\": {\n    \"public\": \"\u003csomeDir\u003e\",\n    \"rewrites\": [\n      {\n        \"source\": \"**\",\n        \"function\": \"\u003cfunctionName\u003e\"\n      }\n    ]\n  },\n  \"functions\": {\n    \"source\": \"\u003canotherDir\u003e\"\n  }\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003emultiple Hosting site with Cloud Function rewrite\u003c/summary\u003e\n\n```json\n{\n  \"hosting\": [\n    {\n      \"site\": \"blog\",\n      \"public\": \"\u003csomeDir\u003e\",\n      \"rewrites\": [\n        {\n          \"source\": \"**\",\n          \"function\": \"\u003cfunctionName\u003e\"\n        }\n      ]\n    },\n    {\n      // another site config\n    }\n  ],\n  \"functions\": {\n    \"source\": \"\u003canotherDir\u003e\"\n  }\n}\n```\n\nTo correctly lookup the `blog` site, `target` will need to be set in\n`svelte.config.js`:\n\n```js\nimport firebase from \"svelte-adapter-firebase\";\n\n/** @type {import('@sveltejs/kit').Config} */\nexport default {\n  kit: {\n    adapter: firebase({ target: \"blog\" }),\n  },\n};\n```\n\n\u003c/details\u003e\n\n### Adapter Configurations\n\nDetailed examples of the adapter configuration options.\n\nAll options:\n\n```js\nimport firebase from \"svelte-adapter-firebase\";\n\n/** @type {import('@sveltejs/kit').Config} */\nexport default {\n  kit: {\n    adapter: firebase({\n      esbuildBuildOptions: (defaultOptions: BuildOptions) =\u003e Promise\u003cBuildOptions\u003e | BuildOptions,\n      firebaseJsonPath: \"\",\n      target: \"svelte-func-single-site\",\n      sourceRewriteMatch: \"\",\n    }),\n  },\n};\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003eesbuildBuildOptions\u003c/code\u003e\u003c/summary\u003e\n\nAs an escape hatch, you may optionally specify a function which will receive the\nfinal esbuild options generated by this adapter and returns a modified esbuild\nconfiguration. The result of this function will be passed as-is to esbuild. The\nfunction can be async.\n\nFor example, you may wish to add `plugins`, or configure the\n[`format`](https://esbuild.github.io/api/#format) to bundle to ESM (defaults to\nCJS):\n\n```js\nimport firebase from \"svelte-adapter-firebase\";\n\n/** @type {import('@sveltejs/kit').Config} */\nexport default {\n  kit: {\n    adapter: firebase({\n      target: \"svelte-func-single-site\",\n      esbuildBuildOptions(defaultOptions) {\n        return {\n          ...defaultOptions,\n          target: \"esm\"\n          plugins: [],\n        };\n      },\n    })\n  },\n};\n```\n\nThe default options for this version are as follows:\n\n```js\n{\n\tentryPoints: ['.svelte-kit/firebase/handler.js'],\n\toutfile: `pathToOutputDir/index.js`,\n\tbundle: true,\n\tinject: ['pathTo/shims.js'],\n\tplatform: 'node',\n  target: `node${functionRuntimeVersion}`\n}\n```\n\nwhere esbuild `target` is computed from the Node.js runtime version defined for\nyour Cloud Functions.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003efirebaseJsonPath\u003c/code\u003e\u003c/summary\u003e\n\nIf the `firebase.json` file is not in the directory you run `svelte build`, then\nyou can set a relative path in `svelte.config.js`:\n\n```\n.gitignore\nfirebase.json\napp/                    \u003c-- svelte build run in this dir\n\tpackage.json\n\tsvelte.config.js\n\tsrc/\nanotherApp/\n\tindex.html\n\tindex.css\nfunctions/\n\tpackage.json\n\tindex.js\n```\n\n```js\nimport firebase from \"svelte-adapter-firebase\";\n\n/** @type {import('@sveltejs/kit').Config} */\nexport default {\n  kit: {\n    adapter: firebase({\n      target: \"svelte-func-single-site\",\n      firebaseJsonPath: \"../firebase.json\",\n    }),\n  },\n};\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/summary\u003e\n\nIf `firebase.json:hosting` is an array of sites, then each hosting config must\nlist a `site` or `target` field that matches the adatper's `target` option. For\nexample:\n\n```json\n// firebase.json\n{\n  \"hosting\": [\n    {\n      \"site\": \"blog\",\n      // or\n      // \"target\": \"blog\",\n      \"public\": \"\u003csomeDir\u003e\",\n      \"rewrites\": [\n        {\n          \"source\": \"**\",\n          \"run\": {\n            \"serviceId\": \"\u003ccloudRunServiceId\u003e\"\n          }\n        }\n      ]\n    },\n    {\n      \"site\": \"adminPanel\",\n      // or\n      // \"target\": \"adminPanel\",\n      \"public\": \"\u003canotherDir\u003e\"\n    }\n  ]\n}\n```\n\n```js\nimport firebase from \"svelte-adapter-firebase\";\n\n/** @type {import('@sveltejs/kit').Config} */\nexport default {\n  kit: {\n    adapter: firebase({ target: \"blog\" }),\n    target: \"#svelte\",\n  },\n};\n```\n\nThe Firebase config \u0026 adapter config match (`firebase.json:hosting[0].site` ===\nadapter `target`), so therefore we know which Firebase Hosting site you want to\nbuild the SvelteKit site for.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003esourceRewriteMatch\u003c/code\u003e\u003c/summary\u003e\n\nIf the rewrite `source` pattern is not `**`, then `svelte.config.js`\n`sourceRewriteMatch` will need to be set to match your desired rewrite rule. For\nexample:\n\n```json\n// firebase.json\n{\n  \"hosting\": {\n    \"public\": \"\u003csomeDir\u003e\",\n    \"rewrites\": [\n      {\n        \"source\": \"/blog/**\",\n        \"run\": {\n          \"serviceId\": \"\u003ccloudRunServiceId\u003e\"\n        }\n      }\n    ]\n  }\n}\n```\n\n```js\nimport firebase from \"svelte-adapter-firebase\";\n\n/** @type {import('@sveltejs/kit').Config} */\nexport default {\n  kit: {\n    adapter: firebase({ sourceRewriteMatch: \"/blog/**\" }),\n    target: \"#svelte\",\n  },\n};\n```\n\n\u003c/details\u003e\n\n## How it works\n\nGiven\n\n- the following `firebase.json` configuration\n- a standard SvelteKit app structure\n- the default `svelte-adapter-firebase` config\n\n```json\n// firebase.json\n{\n  \"hosting\": {\n    \"public\": \"myApp\",\n    \"rewrites\": [\n      {\n        \"source\": \"**\",\n        \"function\": \"ssrServer\"\n      }\n    ],\n    \"predeploy\": [\"npm run build\"]\n  },\n  \"functions\": {\n    \"source\": \"functions\"\n  }\n}\n```\n\nthe following Server \u0026 Static assets dirs are created:\n\n```\nfirebase.json (\"public\": \"myApp\")\npackage.json\nsvelte.config.js\nsrc/\n\tapp.html\n\troutes/\n\t\tindex.svelte\nfunctions/\n\tpackage.json (\"main\": \"index.js\")\n\tindex.js\n\tsveltekit/\t\t\u003c-- Server Assets dir (code to be imported to you Cloud Function)\nmyApp/\t\t\t\t\u003c-- Static Assets to go to Firebase Hosting CDN\n```\n\n- `firebase.json:functions.source` dir is used to find `functions/package.json`\n  whose `main` field is used to find the Cloud Function build dir. This is used\n  as the server asset output dir.\n\n\u003cdetails\u003e\n  \u003csummary\u003eTypeScript Cloud Functions\u003c/summary\u003e\n\nBecause we use the above method to determine the output dir, the server assets\nare output to the correct place when using TypeScript.\n\n```\nfirebase.json (\"public\": \"myApp\")\npackage.json\nsvelte.config.js\nsrc/\n  app.html\n  routes/\n    index.svelte\nfunctions/\n  package.json (\"main\": \"lib/index.js\")\n  index.ts\n  lib/\n    index.js\n    sveltekit/\t\u003c-- Server assets output to functions/lib\nmyApp/\t\t\t\t\u003c-- Static assets to go to Firebase Hosting CDN\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eOutput with Multiple Sites\u003c/summary\u003e\n\nIn a multi-site setup, the `site` or `target` field from hosting config in\n`firebase.json` is used as the server output dir:\n\n```\nfirebase.json (\"site\": \"myCoolSite\",\"public\": \"myApp\")\npackage.json\nsvelte.config.js\nsrc/\n\tapp.html\n\troutes/\n\t\tindex.svelte\nfunctions/\n\tpackage.json\n\tindex.js\n\tmyCoolSite/\t\t\u003c-- Server assets\nmyApp/\t\t\t\t\u003c-- Static assets to go to Firebase Hosting CDN\n```\n\n\u003c/details\u003e\n\nThe final piece is to write the actual Cloud Function source code to reference\nthe output server assets. The code is printed during `svelte build` and should\nbe placed in your `index.js` or `index.ts` manually.\n\nThis is a flexible solution that allows integrating with other Cloud Functions\nin your project. You can edit the provided code as you see fit. The\nimport/require of the generated code will not change unless you change the\n`firebase.json:hosting.site` or `package.json:main` fields, so you shouldn't\nneed to update this code after adding it.\n\n## Firebase Emulator local Testing\n\nTest your production build locally before pushing to git or deploying!\n\n- build your app: `svelte-kit build`\n- install Function dependencies: `pnpm install --prefix functions`\n- start the emulator: `firebase emulators:start`\n\n## Deployment\n\n`firebase deploy` :tada:\n\n## Caveats\n\n- Using `firebase.json:hosting[].site` is preferred to\n  `firebase.json:hosting[].target` as\n  [Firebase Deploy Targets](https://firebase.google.com/docs/cli/targets) only\n  supports Hosting, Storage \u0026 Databases and not Functions. This means you can\n  use Deploy targets `target` field to identify your site for the adapter to\n  **build**, but you **CANNOT use Deploy Targes when deploying** as you need to\n  deploy the Hosting _\u0026 Functions_ at the same time for this solution to work as\n  expected.\n- [Firebase Hosting Preview Channels](https://firebase.google.com/docs/hosting/test-preview-deploy)\n  currently lacks first-party support for SSR applications. This adapter doesn't\n  attempt to remedy this issue and doesn't produce a different SSR Function for\n  preview channel deployments.\n- :warning: Cloud Function rewrites only support **us-central1**, other regions\n  will error. The official warning about this can be found in\n  [these docs](https://firebase.google.com/docs/hosting/functions).\n\n## Non-goals\n\n\u003e Write Cloud Function code directly into `.js` file instead of printing in\n\u003e console.\n\nFirebase Cloud Functions have a long history of people configuring their index\nfiles completely differently, some even generating them from directories.\nAccommodating these would be a headache. Instead, all we look for is a match\nagainst this string, `${name} =`, where `name` is your Cloud Functions name. We\nmay make this configurable to a specific file in future.\n\nAdditionally, this allows for users to customise their Firebase Cloud Function\nAPI like `runWith()` options for memory/CPU, min/max Instances and\nVPC/Ingress/Egress configuration settings, without complex support for options\nin the adapter. This keeps the Function config where it should, close to the\nuserland code.\n\n\u003e Handle the deployment of the app to Firebase.\n\nFirebase apps consist of many different services with the CLI providing optional\ndeployments. We do not want to dictate full deployments with your frontend nor\nperform partial deployments if it does not fit your app. The only option then is\nto leave it to you :tada:\n\n## FAQ\n\n\u003e Why is the Cloud Function code output to the terminal for me to add manually\n\u003e instead of being written to `functions/index.js`?\n\nSee [non-goals](#non-goals) _Write Cloud Function code directly into `.js` file\ninstead of printing in console._\n\n\u003e Firebase libs in SvelteKit\n\nAs recommended in the [SvelteKit FAQ](https://kit.svelte.dev/faq), please use\n[Firebase JS SDK v9](https://firebase.google.com/docs/web/learn-more#modular-version)\nas the older version of the SDK has issues and a larger bundle size.\n\n\u003e Cold Starts\n\nSince the purpose of using this adapter is to leverage the Firebase Hosting CDN,\nyou should consider improving the user experience with targetted caching/TTLs.\n\nIf cold start are still an issue for your application, Cloud Functions has\nsupport for `minInstances` which will keep `X` number of instances warm. From\nthe docs:\n\n\u003e A minimum number of instances kept running incur billing costs at idle rates.\n\u003e Typically, to keep one idle function instance warm costs less than $6.00 a\n\u003e month. The Firebase CLI provides a cost estimate at deployment time for\n\u003e functions with reserved minimum instances. Refer to Cloud Functions Pricing to\n\u003e calculate costs.\n\u003e\n\u003e -[Firebase docs](https://firebase.google.com/docs/functions/manage-functions#min-max-instances)\n\nTo implement this, configure your\n[`runWith`](https://github.com/firebase/firebase-functions/blob/d46ec6191e61f560f3f21f13333e0f3285d3de90/src/function-configuration.ts#L101)\noptions like so:\n\n```diff\nconst myRuntimeOptions = {\n\tmemory: \"1GB\",\n+\tminInstances: 1,\n}\nexports.myFunc = functions.runWith(myRuntimeOptions).https.onRequest(async (request, response) =\u003e {\n\t...\n});\n```\n\nNote: this is still single concurrency (if an instance does not exist to handle\na request when it hits the backend a new Function instance is created). Watch\nthis space!\n\n\u003c!-- TODO: on 1.0.0 release, delete this section --\u003e\n\n- `1.0.0` will not be published until the SvelteKit Adapter API is declared\n  stable and SvelteKit is released for general use.\n\n\u003c!-- END --\u003e\n\n## Contributing\n\n[Contributions of any kind welcome, just follow the\nguidelines](CONTRIBUTING.md)!\n\nShort version:\n\n```\ngit clone https://github.com/jthegedus/svelte-adapter-firebase.git\nasdf install\npnpm i\n```\n\nSee [asdf](https://asdf-vm.com) to install set it up.\n\n### external contributions\n\nWhile building this adapter some issues were found with upstream components,\nthese are captured here should someone wish to contribute them:\n\n- Cloud Function validation code linked in `utils.js` is from two different\n  sources which indicates that it is being validated by `firebase-tools` in two\n  separate places. PR a fix there.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjthegedus%2Fsvelte-adapter-firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjthegedus%2Fsvelte-adapter-firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjthegedus%2Fsvelte-adapter-firebase/lists"}