tezvyn:

🌐Frontend Dev

Frontend web development and UI engineering

498 bites

Vue, Angular & Svelte30 sec read

Svelte Derived Stores: Reactive Values from Other Stores

A Svelte derived store is like a spreadsheet formula for your state. It listens to other stores and automatically computes a new value whenever they change. The footgun is trying to write to it—it's read-only; you must update its sources instead.

Vue, Angular & Svelte30 sec read

Svelte Stores: State for Async Streams & Legacy Apps

Svelte Stores are objects for sharing reactive state. While Svelte 5's runes (`$state`) are now preferred for simple state sharing, stores remain ideal for complex async streams or when you need manual control over updates.

Vue, Angular & Svelte30 sec read

Svelte's Reactive Assignments with `$: `

Think of Svelte's `$: ` as a magic label that automatically re-runs code when its inputs change. It's used to create derived values, like `$: sum = a + b`. The footgun: the compiler only tracks direct dependencies, not those hidden inside function calls.

Vue, Angular & Svelte30 sec read

Svelte Lifecycle: Mount, Destroy, and Tick

Svelte 5 simplifies the component lifecycle to just two events: creation (`onMount`) and destruction (`onDestroy`). Use `onMount` for DOM setup and return a cleanup function from it. The cleanup only works if the main callback is synchronous, not async.

Vue, Angular & Svelte30 sec read

Angular Component Lifecycle Hooks

Angular's lifecycle hooks are callbacks for a component's life events: creation, updates, and destruction. Use ngOnInit for one-time setup after inputs are ready, and ngOnChanges to react to input changes. The footgun: don't use the constructor for setup.

Vue, Angular & Svelte30 sec read

*ngFor trackBy: Smarter DOM Updates in Angular

*ngFor's `trackBy` tells Angular how to uniquely identify items in a list. This prevents it from destroying and recreating the entire list in the DOM on every data update, instead allowing it to reuse existing elements.

Vue, Angular & Svelte30 sec read

Svelte Slot Props: Child Informs, Parent Renders

Svelte slot props let a child component pass data up to its parent's slot. This is key for reusable list components where the child provides data for each item, but the parent controls the rendering. The footgun: the `let:` directive goes on the component tag.

Vue, Angular & Svelte30 sec read

Svelte Context API: Avoid Prop-Drilling

Svelte's Context API lets a parent component provide data to any descendant, avoiding 'prop-drilling'. It's ideal for sharing app-wide state like user info or themes. The key footgun: calling `getContext` without a parent `setContext` will throw an error.

Vue, Angular & Svelte30 sec read

Angular Content Projection with ng-content

ng-content creates a "slot" in a component's template, letting you project parent content into it. Use this for reusable wrappers like cards or dialogs. The key footgun: never use @if on ng-content, as the content is always rendered, even if hidden.

Vue, Angular & Svelte30 sec read

Angular's input() Function: Passing Data to Components

Angular's input() function lets a parent pass data to a child, defining the child's public API. Use it to configure a component, like passing a `value` to a slider. The footgun: the returned signal is read-only; the child cannot modify its own input.

Vue, Angular & Svelte30 sec read

Vite's Dependency Pre-Bundling

Vite's dev server pre-bundles dependencies to accelerate local development. It converts CommonJS modules to browser-native ESM and merges packages with many files into one, preventing massive HTTP request chains.

Vue, Angular & Svelte30 sec read

SvelteKit Hooks: Intercepting Requests and Events

SvelteKit Hooks are like middleware, letting you intercept requests and events to run app-wide logic. Use them for tasks like authentication checks, initializing DB clients, or custom routing.

Vue, Angular & Svelte31 sec read

Vite's Low-Level SSR API

Vite's SSR API lets you run Vite as a middleware inside your own Node.js server, giving you full control over rendering. It's for building custom SSR solutions, often with Express. The footgun: most apps should use a higher-level SSR plugin, not this API.

Vue, Angular & Svelte30 sec read

Vite's Plugin System: Extending Dev and Build

Vite's plugin system extends its dev server and build process, leveraging Rollup's mature ecosystem. Use it to add framework support or handle custom assets. The footgun is forgetting to control execution order with `enforce`, causing compatibility issues.

Vue, Angular & Svelte30 sec read

SvelteKit Adapters: Bridge Your App to Production

A SvelteKit adapter is a power plug for your app, making your universal build fit a specific deployment target like Vercel or a Node server. You configure it based on your host, like `adapter-static` for static sites. The footgun is forgetting one entirely.

Vue, Angular & Svelte30 sec read

Vite Config: The Control Panel for Your Build

Think of `vite.config.js` as a dynamic script, not a static file. It lets you programmatically change your build based on context, like serving for development versus building for production.

Vue, Angular & Svelte30 sec read

Vite's HMR API: Manually Controlling Hot Reloads

Vite's HMR API lets a module handle code changes without a full reload. While frameworks usually manage this, you can use it for custom tooling. The footgun: forgetting to wrap HMR code in `if (import.meta.hot)` will crash your production build.

Vue, Angular & Svelte31 sec read

SvelteKit: From Zero to Dev Server

Spin up a new SvelteKit app with `npx sv create`. This command scaffolds a project, prompting you to add tools like TypeScript. Then, `npm run dev` starts your dev server. The key footgun: forgetting to install dependencies before starting the server.

Vue, Angular & Svelte30 sec read

Scaffolding a Vite Project with `create-vite`

Use `create-vite` to instantly generate a new web project with your chosen framework. It's the fastest way to start a Vue, React, or Svelte app without manual setup. The footgun is forgetting you can pass a `--template` flag to skip interactive prompts.

Vue, Angular & Svelte30 sec read

Why Svelte Skips the Virtual DOM

Svelte skips the Virtual DOM, treating it as runtime overhead. It acts as a compiler, generating precise JavaScript to update the DOM directly. This avoids the 'diffing' step of frameworks like React, leading to smaller bundles and faster updates.