惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
Kaspersky official blog
V
Visual Studio Blog
The Register - Security
The Register - Security
A
About on SuperTechFans
W
WeLiveSecurity
Attack and Defense Labs
Attack and Defense Labs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
Security @ Cisco Blogs
Google Online Security Blog
Google Online Security Blog
U
Unit 42
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Securelist
T
Tenable Blog
Help Net Security
Help Net Security
Recorded Future
Recorded Future
S
Secure Thoughts
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The GitHub Blog
The GitHub Blog
G
GRAHAM CLULEY
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
MyScale Blog
MyScale Blog
The Hacker News
The Hacker News
H
Heimdal Security Blog
Microsoft Security Blog
Microsoft Security Blog
博客园 - 三生石上(FineUI控件)
Project Zero
Project Zero
T
Threat Research - Cisco Blogs
J
Java Code Geeks
T
Threatpost
Cyberwarzone
Cyberwarzone
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
S
Security Affairs
Security Latest
Security Latest
Martin Fowler
Martin Fowler
C
Cyber Attacks, Cyber Crime and Cyber Security
T
The Exploit Database - CXSecurity.com
Cisco Talos Blog
Cisco Talos Blog
L
LINUX DO - 热门话题
宝玉的分享
宝玉的分享
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - Franky
C
CERT Recently Published Vulnerability Notes

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
How We Migrated Bloom After from Vanilla JS to Next.js + TypeScript
Chijioke Uzodinma · 2026-06-27 · via DEV Community

As part of Rise Academy's frontend program, students are grouped and assigned real projects to work on. My group was assigned Bloom After — and our task was to migrate its existing Vanilla JS frontend to Next.js with TypeScript. Not because the old one was broken, but because that's exactly the kind of thing you need to do once on a real codebase before you can say you actually know how. I was the one who set up the new project and made most of the architectural decisions, so this is a first-hand account of how we approached it.


Why We Migrated

Honestly? The legacy frontend still worked. This wasn't a "the codebase is on fire" situation — it was a deliberate learning exercise set by Rise Academy. Bloom After was one of three projects assigned across student groups, and the task was to migrate it to a modern stack. Part of the value of Rise Academy's program is that you work on real projects, not toy examples — so the problems you encounter are real too.

That said, the migration did surface real problems worth solving:

  • Inconsistent data shapes. Some backend responses used _id, others id. Some used desc, others description. Messy in any codebase, good to clean up.
  • Auth in localStorage. Fine for a learning project, but not a habit worth keeping — so we fixed it properly.
  • No enforced structure. As the team grew, having no patterns made it easy to do things differently every time.

The goal wasn't to rescue a broken app. It was to learn migration — and learn it on something real enough to matter.


The Setup Decisions I Made Before Anyone Wrote a Single Component

Before I let anyone start building, I made a few calls that I think saved us a lot of pain.

1. Keep CSS Class Names the Same

The legacy app had a full stylesheet. Rather than rewriting CSS, I told the team: keep every class name identical to what it was in the Vanilla JS version. We only import the CSS a page actually needs, not a global dump of everything.

This meant:

  • No duplicate styling work
  • No visual regressions from class name mismatches
  • Designers and devs could reference the same class names they already knew

2. Route Groups for Shared Layouts

Next.js App Router supports route groups — folders wrapped in parentheses that don't affect the URL but let you share layouts. I used this heavily:

app/
├── (public)/          # Marketing pages — shared public header
├── (admin)/           # Admin pages — shared admin header
└── (dashboard)/       # User dashboard — shared sidebar

Each group gets its own layout.tsx, so the right header/sidebar renders automatically without any conditional logic inside components.

3. Normalise the Data at the Type Layer

Before writing a single component, I created TypeScript interfaces that reflected what the data should look like — not what the backend was actually sending. Then I wrote normalisation utilities to map the messy API responses into clean, predictable shapes.

// types/course.ts
export interface Course {
  id: string;           // normalised from _id or id
  title: string;
  description: string;  // normalised from dead or description
  createdAt: string;
}

// utils/normalise.ts
export function normaliseCourse(raw: Record<string, unknown>): Course {
  return {
    id: (raw._id ?? raw.id) as string,
    title: raw.title as string,
    description: (raw.description ?? raw.dead) as string,
    createdAt: raw.createdAt as string,
  };
}

This is one of the biggest wins TypeScript gave us. Once the normalisation layer existed, every component downstream could trust the shape of its data.


Week 1: Foundation

The Index Page + First Components

I started with the index page to validate the setup end-to-end — routing, CSS imports, layout — before anyone else touched the codebase. Once that was solid, I built the first two shared components:

  • TeamMembers — displays the team section on the public-facing pages
  • SuggestionDrawer — a slide-in drawer for user suggestions

These were deliberately simple. I wanted them as reference points for how components should be structured in this project before other team members started contributing.

api.ts — The Single HTTP Client

Instead of letting every file do its own fetch, I created a centralised HTTP client:

// lib/api.ts
const BASE_URL = process.env.NEXT_PUBLIC_API_URL;

async function request<T>(
  method: string,
  endpoint: string,
  body?: unknown
): Promise<T> {
  const res = await fetch(`${BASE_URL}${endpoint}`, {
    method,
    headers: { "Content-Type": "application/json" },
    body: body ? JSON.stringify(body) : undefined,
    credentials: "include",
  });

  if (!res.ok) throw new Error(`${method} ${endpoint}${res.status}`);
  return res.json();
}

export const api = {
  get: <T>(endpoint: string) => request<T>("GET", endpoint),
  post: <T>(endpoint: string, body: unknown) => request<T>("POST", endpoint, body),
  patch: <T>(endpoint: string, body: unknown) => request<T>("PATCH", endpoint, body),
  del: <T>(endpoint: string) => request<T>("DELETE", endpoint),
};

Then I created lifestyle-api.ts — a thin wrapper around api.ts that scoped all requests to the /lifestyle backend route. This gave other team members a focused, simple API surface for that part of the product without them needing to know the full backend structure.


Week 2: Admin, Auth, and Access Control

Reworking Authentication — localStorage → Cookies

The legacy frontend stored the auth token in localStorage. That's fine for simple apps, but it's vulnerable to XSS and it makes server-side auth checks impossible. I migrated to NextAuth with httpOnly cookies.

The key pieces:

Custom API routes for login/logout:

// app/api/auth/login/route.ts
import { cookies } from "next/headers";

export async function POST(req: Request) {
  const { email, password } = await req.json();

  const res = await fetch(`${process.env.API_URL}/auth/login`, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ email, password }),
  });

  if (!res.ok) return Response.json({ error: "Invalid credentials" }, { status: 401 });

  const { token } = await res.json();

  cookies().set("token", token, {
    httpOnly: true,
    secure: process.env.NODE_ENV === "production",
    sameSite: "lax",
    path: "/",
  });

  return Response.json({ ok: true });
}

// app/api/auth/logout/route.ts
import { cookies } from "next/headers";

export async function POST() {
  cookies().delete("token");
  return Response.json({ ok: true });
}

The token never touches the client — it lives in an httpOnly cookie the browser manages automatically.

Middleware for Protected Routes

Next.js middleware runs before a request hits any page. I used it to protect all admin routes:

// middleware.ts
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";

export function middleware(request: NextRequest) {
  const token = request.cookies.get("token");

  if (!token) {
    return NextResponse.redirect(new URL("/login", request.url));
  }

  return NextResponse.next();
}

export const config = {
  matcher: ["/admin/:path*"],
};

Clean, centralised, impossible to bypass by navigating directly to a URL.

Admin Pages

With auth solid, I built out:

  • Admin Dashboard — overview metrics, quick actions
  • Admin Navbar + Sidebar — shared layout components inside (admin)/layout.tsx
  • Admin Renderers — reusable display components used across dashboard views
  • /admin/content-manager — lists all content pieces
  • /admin/content-manager/editor — full rich-text editor for creating and updating content

On the Deployment Strategy

I own all deployments — both the new Next.js frontend and the backend. The legacy Vanilla JS frontend is still live and running in parallel.

My personal take on how this should be handled: don't rush killing the legacy version. If I had the call, I'd keep both live for at least a month after the new one is stable, watch for unexpected errors, and only decommission the old one once we're confident. For a product with active users, the right approach is a gradual traffic migration — send a small percentage to the new frontend, validate it handles the load, then shift everyone over. Rushing that step is how you cause an outage.


What I'd Do Differently

  • Set up the normalisation layer before anything else, not alongside the first components. A week in, I was backfilling types for things I'd already built.
  • Document the route group structure on day one. A few teammates added pages in the wrong group early on because the convention wasn't written down yet.
  • Add a shared error boundary early. We added it later and had to retrofit it — easier to start with one.

Maintenance

The new frontend is now in active development. I maintain it going forward. The backend and legacy frontend are maintained by Grace.


Final Thoughts

Migrations are less about the code and more about the decisions you make before you write any. The CSS class naming convention, the route groups, the normalisation layer, the single HTTP client — none of those are complicated individually. Together, they made it possible for a small team to move fast without creating a new mess to replace the old one.

If you're planning a similar migration, the main thing I'd say is: design the constraints first, then build inside them.


Found this useful? Drop a reaction or share it — and feel free to ask questions in the comments.