Slide 1

Slide 1 text

Intro to Analog.js the Angular meta-framework Marcell Kiss, 2024

Slide 2

Slide 2 text

Intro Marcell Kiss, MSc Contractor #EnterpriseArchitecture Angular Hungary 🇭🇺 Part-time trainer #AngularArchitects marcellkiss.com @marcelltech @marcellkiss @marcellkiss 🇩🇪

Slide 3

Slide 3 text

What is a meta-framework? @marcelltech

Slide 4

Slide 4 text

Web Rendering CSR - Client-Side Rendering SSR - Server-Side Rendering SSG - Static Site Generation

Slide 5

Slide 5 text

CSR - Client-Side Rendering Server Browser somesite.com index.html [empty shell] Include main.js main.js Request: …/api/info {info: …} 👀 ⚙ @marcelltech

Slide 6

Slide 6 text

Server Browser somesite.com Include main.js main.js 👀 SSR - Server-Side Rendering index.html [with content!] ⚙ @marcelltech ⚙

Slide 7

Slide 7 text

SSG - Static Site Generation Server Browser somesite.com index.html [with content!] Include main.js main.js 👀 ⚙ @marcelltech

Slide 8

Slide 8 text

Performance Summary ❌ CSR is resource-heavy for bots ❌ SSR is resource-heavy for us ✅ SSG has the lowest latency @marcelltech

Slide 9

Slide 9 text

Tribute to Brandon Roberts @marcelltech Start date: July, 2022 Current version: v1.3.1 Contributors: 108 Stars on GitHub: 2.3k Members on Discord: 670

Slide 10

Slide 10 text

Analog.js features • Vite builder • File-based routing • API routes • Server-Side data fetching • Static Site Generation • Vitest • Deployment providers

Slide 11

Slide 11 text

Installation @marcelltech

Slide 12

Slide 12 text

Wait, Analog uses Vite? 👀 @marcelltech

Slide 13

Slide 13 text

HMR in React @marcelltech

Slide 14

Slide 14 text

HMR in Angular 😢 @marcelltech

Slide 15

Slide 15 text

File-based routing @marcelltech /about.page.ts /about /products/[productId].page.ts /products/:productId Static routes Dynamic routes /(auth)/login.page.ts /login Grouped routes Put your f iles under src/app/pages … ├── products/ │ ├── [productId].page.ts │ └── (products-list).page.ts └── products.page.ts /products /products/:productId Layout routes /[...page-not-found].page.ts /** Catch-all routes Source: https://analogjs.org/docs/features/routing/overview

Slide 16

Slide 16 text

De f ine Metadata @marcelltech Source: https://analogjs.org/docs/features/routing/metadata

Slide 17

Slide 17 text

API routes @marcelltech /test.ts /api/test Put your f iles under src/server/routes /api/** /[…]ts POST /api/test /test.post.ts Works with .get, .post, .put, .delete Catch-all routes /api/products/:productId /products/[productId].ts Dynamic routes Source: https://analogjs.org/docs/features/api/overview

Slide 18

Slide 18 text

Server-Side data fetching @marcelltech test.server.ts

Slide 19

Slide 19 text

Server-Side data fetching (2) @marcelltech test.page.ts

Slide 20

Slide 20 text

Static Site Generation @marcelltech vite.con f ig.ts

Slide 21

Slide 21 text

Vitest @marcelltech home.page.spec.ts

Slide 22

Slide 22 text

Vitest (2) @marcelltech > npm run test

Slide 23

Slide 23 text

Build it @marcelltech > npm run build dist |- analog |- public |- server |- client |- ssr > node dist/analog/server/index.mjs

Slide 24

Slide 24 text

Deployment Providers @marcelltech • Netlify • Vercel • Cloud f lare Pages • Firebase • render.com • Edgio

Slide 25

Slide 25 text

Deploy to Netlify @marcelltech Publish directory => dist/analog/public (deploy static assets) Functions directory => dist/analog (deploy server)

Slide 26

Slide 26 text

Deploy to Netlify @marcelltech

Slide 27

Slide 27 text

We didn’t talk about… @marcelltech - Content Routes (.md f iles) - Code Generation - Auto-updates - Nx integration - SFC - Single File Components

Slide 28

Slide 28 text

Marcell Kiss, 2024 Questions and Answers Thanks for listening! marcellkiss.com @marcelltech @marcellkiss @marcellkiss

Slide 29

Slide 29 text

Resources @marcelltech [Article] Angular Islands in Astro https://dev.to/brandontroberts/bringing-angular-components-to-astro-islands-52jp [Article] Astro + Angular https://medium.com/ngconf/astro-angular-abe926dac097 [Docs] Angular new build system https://angular.io/guide/esbuild [Docs] Angular Pre-rendering https://angular.dev/guide/prerendering# [Docs] Astro integrations https://astro.build/integrations/ [Docs] Astro MDX Docs https://docs.astro.build/en/guides/integrations-guide/mdx/ [OSS] GitHub Repo https://github.com/marcellkiss/angular-astro-example