Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brandonroberts/analog-angular-firebase-example
An example application with Analog and Angular that deploys to Firebase hosting and functions
https://github.com/brandonroberts/analog-angular-firebase-example
angular firebase meta-framework ssr
Last synced: 3 months ago
JSON representation
An example application with Analog and Angular that deploys to Firebase hosting and functions
- Host: GitHub
- URL: https://github.com/brandonroberts/analog-angular-firebase-example
- Owner: brandonroberts
- Created: 2023-05-12T02:27:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-09T19:19:18.000Z (11 months ago)
- Last Synced: 2024-05-01T23:14:00.849Z (8 months ago)
- Topics: angular, firebase, meta-framework, ssr
- Language: TypeScript
- Homepage: https://analog-js.web.app
- Size: 658 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Analog + Angular + Firebase
This project was generated with [Analog](https://analogjs.org), the fullstack meta-framework for Angular.
## Setup
Run `npm install` to install the application dependencies.
## Development
Run `npm start` for a dev server. Navigate to `http://localhost:5173/`. The application will automatically reload if you change any of the source files.
## Build
Run `npm run build` to build the client/server project. The client build artifacts are located in the `dist/analog/client` directory. The server for the API build artifacts are located in the `dist/analog/server` directory.
## Test
Run `npm run test` to run unit tests with [Vitest](https://vitest.dev).
## Firebase Deployment
Analog supports [Firebase Hosting](https://firebase.google.com/docs/hosting) with Cloud Functions out of the box.
**Note**: You need to be on the **Blaze plan** to use Analog with Cloud Functions.
If you don't already have a `firebase.json` in your root directory, Analog will create one the first time you run it. In this file, you will need to replace `` with the ID of your Firebase project.
This file should then be committed to version control. You can also create a `.firebaserc` file if you don't want to manually pass your project ID to your `firebase` commands (with `--project `):
```json [.firebaserc]
{
"projects": {
"default": ""
}
}
```Then, just add Firebase dependencies to your project:
```bash
npm install -D firebase-admin firebase-functions firebase-functions-test
```### Using Firebase CLI
You may instead prefer to set up your project with the Firebase CLI, which will fetch your project ID for you, add required dependencies (see above) and even set up automated deployments via GitHub Actions.
#### Install Firebase CLI globally
```bash
npm install -g firebase-tools
```**Note**: You need to be on [^11.18.0](https://github.com/firebase/firebase-tools/releases/tag/v11.18.0) to deploy a nodejs18 function.
#### Initialize your Firebase project
```bash
firebase login
firebase init hosting
```When prompted, you can enter `dist/analog/public` as the public directory. In the next step, **do not** configure your project as a single-page app.
Once complete, add the following to your `firebase.json` to enable server rendering in Cloud Functions:
```json [firebase.json]
{
"functions": { "source": "dist/analog/server" },
"hosting": [
{
"site": "",
"public": "dist/analog/public",
"cleanUrls": true,
"rewrites": [{ "source": "**", "function": "server" }]
}
]
}
```You can find more details in the [Firebase documentation](https://firebase.google.com/docs/hosting/quickstart).
## Local preview
You can preview a local version of your site if you need to test things out without deploying.
```bash
NITRO_PRESET=firebase npm run build
firebase emulators:start
```## Deploy to Firebase Hosting via CLI
Deploying to Firebase Hosting is a simple matter of just running the `firebase deploy` command.
```bash
NITRO_PRESET=firebase npm run build
firebase deploy
```## Community
- Join the [Discord](https://discord.gg/mKC2Ec48U5)
- Visit and Star the [GitHub Repo](https://github.com/analogjs/analog)
- Visit the [Website](https://analogjs.org/)
- Follow us on [Twitter](https://twitter.com/analogjs)