Modern Web Development: A Complete 2026 Guide
A current, practical guide to modern web development: React 19, Next.js 16, RSC, modern CSS, Core Web Vitals (INP), accessibility, and AI.
Read Modern Web Development: A Complete 2026 ...A practical, current guide to securing web apps: OWASP Top 10, XSS, CSRF, auth/JWT, secure headers, injection defense, secrets, and TLS.
Web applications are attacked continuously, and the attack surface keeps growing: richer client-side JavaScript, sprawling third-party dependencies, API-first backends, and identity flows that span multiple services. Security is not a feature you bolt on at the end — it is a property you design in and verify continuously.
This guide distills the practices that matter most for modern web applications, grounded in the OWASP Top 10, MDN web security documentation, and web.dev. It is written for defenders: developers, reviewers, and operators who want to ship resilient applications.
The OWASP Top 10 is the industry-standard awareness document for web application risk. Rather than memorizing positions, focus on the recurring themes that drive most real-world breaches:
OWASP also publishes a dedicated API Security Top 10, which is essential reading for backends that serve mobile and single-page apps.
XSS happens when attacker-controlled data is interpreted as executable code in a victim's browser. It remains one of the most common client-side flaws.
The single most important defense is context-aware output encoding: encode data based on where it lands — HTML body, HTML attribute, JavaScript, URL, or CSS contexts each require different escaping.
dangerouslySetInnerHTML, v-html, and [innerHTML] as red flags requiring justification.eval(), element.innerHTML, and document.write() with untrusted data.A strong Content Security Policy is your defense-in-depth backstop. Modern CSPs favor nonces or hashes over allowlisting host domains:
Content-Security-Policy: default-src 'self';
script-src 'self' 'nonce-r4nd0m';
object-src 'none';
base-uri 'none';
require-trusted-types-for 'script'
Trusted Types locks down dangerous DOM injection sinks at the browser level and is one of the strongest anti-DOM-XSS controls available today.
CSRF tricks an authenticated user's browser into submitting a request they did not intend. The defenses have matured:
SameSite=Lax (a sensible default for most apps) or SameSite=Strict for the most sensitive cookies. This blocks most cross-site cookie-driven requests automatically.Cookie flags should be explicit:
Set-Cookie: session=...; HttpOnly; Secure; SameSite=Lax; Path=/
For pure token-based APIs that send credentials in an Authorization header rather than cookies, classic CSRF generally does not apply — but you then inherit the token-storage and XSS concerns discussed below.
Authentication failures are routinely exploited. Build on proven primitives rather than custom schemes.
Passwords and credentials
Sessions
HttpOnly; Secure; SameSite cookies.JWTs — handle with care
JSON Web Tokens are useful but easy to misuse:
alg: none and never let the token header dictate the verification algorithm.iss, aud, and exp claims on every request.localStorage if you can avoid it — it is readable by any XSS payload. Prefer HttpOnly cookies for browser sessions.Security headers are cheap, high-leverage hardening. At minimum, configure:
| Header | Purpose |
|---|---|
Content-Security-Policy | Restrict script/resource sources; primary XSS defense-in-depth |
Strict-Transport-Security | Force HTTPS and prevent protocol downgrade |
X-Content-Type-Options: nosniff | Stop MIME-type sniffing |
Referrer-Policy | Limit referrer leakage (e.g., strict-origin-when-cross-origin) |
Cross-Origin-Opener-Policy | Isolate your browsing context window |
Cross-Origin-Resource-Policy | Control who can embed your resources |
Permissions-Policy | Disable unused browser features (camera, geolocation, etc.) |
Note that X-Frame-Options is superseded by the CSP frame-ancestors directive; use frame-ancestors 'none' (or an explicit allowlist) to prevent clickjacking.
A solid HSTS header, once you are confident in full HTTPS coverage:
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
Validate your configuration against tools like the Mozilla Observatory and MDN's header references.
Validation and output encoding solve different problems and you need both. Validation reduces the attack surface; encoding neutralizes whatever still gets through.
Injection is prevented by separating code from data, not by escaping strings.
SQL — always parameterize:
// Safe: parameterized query, input can never alter the query structure
const user = await db.query(
'SELECT id, email FROM users WHERE email = $1',
[submittedEmail]
);
Avoid string interpolation into queries. Use an ORM or query builder, but understand that ORMs can still emit raw SQL — review any raw() escape hatches. Apply least-privilege database accounts so a compromised query cannot drop tables or read unrelated data.
NoSQL is not immune. Document stores are vulnerable to operator injection when untrusted input becomes a query object. For example, a JSON body of {"password": {"$ne": null}} can bypass a naive MongoDB login check. Defenses:
$where, $ne, etc.) coming from user input.Hardcoded secrets in source control are a perennial cause of breaches.
Most application code today is third-party code. The supply chain is now a primary attack vector.
npm audit, GitHub Dependabot, OWASP Dependency-Check, or Snyk. Patch known-vulnerable components promptly.integrity="sha384-...") for third-party scripts loaded from CDNs.Transport security is the floor, not the ceiling.
testssl.sh.Use this as a pre-launch and periodic review gate:
includeSubDomains.HttpOnly; Secure; SameSite, regenerated on login, with timeouts.alg: none rejected; claims validated; tokens short-lived.Strong web security is layered. No single control — not CSP, not parameterized queries, not MFA — is sufficient alone. The goal is defense in depth: assume any one layer can fail and ensure the next one limits the blast radius.
Treat security as a continuous practice. Threat-model new features, review dependencies on a schedule, keep an inventory of what you run, and test your defenses with automated scanning and periodic penetration testing. The OWASP, MDN, and web.dev resources linked throughout are free, current, and worth bookmarking — they evolve as the threat landscape does, and so should your applications.
Web On Dev designs, builds, and ships production software. Get a free consultation and a transparent quote.
Continue reading with these related articles that you might find interesting.
A current, practical guide to modern web development: React 19, Next.js 16, RSC, modern CSS, Core Web Vitals (INP), accessibility, and AI.
Read Modern Web Development: A Complete 2026 ...A current Next.js guide for 2026: App Router, Server Components, Server Actions, the new caching model, Partial Prerendering, and deployment.
Read The Complete Next.js Guide for 2026 (App...A practical, current guide to TypeScript: strict tsconfig, unions vs enums, satisfies, const type params, narrowing, discriminated unions, and using.
Read TypeScript Best Practices & Advanced Pat...Let's discuss how we can help you achieve your digital goals with our expert team.