Day 4 - Frontend Diaries 👉 I thought frontend just renders data When initially I started working on frontend, my thinking was simple - fetch data from API and show it on the screen But while building, I realized it’s not that straightforward What happens before data arrives? What happens if the request fails? What if there’s no data at all? Just showing data is the easiest part Handling everything around it is where things get tricky Showing loading state while data is being fetched handling errors when something goes wrong managing empty states when there’s nothing to show and keeping everything in sync with the backend Frontend is not just about rendering data it’s about handling all the states that data can be in #frontenddevelopment #reactjs #webdevelopment #fullstackdeveloper #softwareengineering #buildinpublic #developers
Frontend Development Beyond Rendering Data
More Relevant Posts
-
Your users are waiting for tasks they'll never see. Here's the fix. 👇 Most devs write POST routes where emails, analytics, and syncs all run before the response is returned. The user sits there waiting — not because the data isn't ready, but because your side-effects are blocking the thread. Next.js 15 ships a built-in after() API. Response fires instantly. Background work runs after. No queues, no infra, no nonsense. ❌ Blocking tasks The user's request hangs until every side-effect (email, analytics, sync) finishes. One slow service delays the whole response — bad UX, worse performance. ✅ after() — fire & forget Response is sent instantly. Background work runs after — no blocking, no extra infrastructure, no queue needed. Works with Server Actions and Route Handlers. #NextJS #NextJS15 #WebDevelopment #JavaScript #TypeScript #100DaysOfCode #CleanCode #FrontendDeveloper #SoftwareEngineer #WebDev #NodeJS #FullStackDeveloper #Programming #ServerActions #BackendDevelopment #ReactServer #APIDesign #WebPerformance
To view or add a comment, sign in
-
-
Most React devs think they understand useEffect. They don't. And it's costing them subtle bugs in prod. Here's the one thing nobody explains clearly: The cleanup function doesn't run when you think it does. Say you're fetching user data based on a userId prop: > the buggy version useEffect(() => { fetch(`/api/user/${userId}`) .then(res => res.json()) .then(data => setUser(data)); }, [userId]); Looks fine, right? It's not. If userId changes from 1 → 2 quickly, maybe the user is clicking through a list, both requests are in flight. Whichever resolves last wins. You could end up showing user 1's data on user 2's profile. That's a race condition, and it's completely silent. Here's how you fix it with an AbortController: > the correct version useEffect(() => { const controller = new AbortController(); fetch(`/api/user/${userId}`, { signal: controller.signal }) .then(res => res.json()) .then(data => setUser(data)) .catch(err => { if (err.name !== 'AbortError') throw err; }); return () => controller.abort(); }, [userId]); Now when userId changes, React runs the cleanup - which aborts the in-flight request, before firing the new effect. No stale data. No race. No mystery bug at 2am. The cleanup function is not just for "removing event listeners." It's your undo button for whatever the effect started. Timers? Clear them. Subscriptions? Unsubscribe. Requests? Abort them. I've seen this bite senior devs on dashboards, search inputs, and paginated lists more times than I can count. If your useEffect fetches data and has no cleanup, there's a bug waiting to happen. #React #MERN #WebDevelopment #JavaScript #FrontendDevelopment #ReactNative
To view or add a comment, sign in
-
There is a distinct moment in every developer's career when they stop seeing TypeScript as an annoying chore and start seeing it as the ultimate safety net. I remember the early days of hunting down vague runtime errors that completely broke a user interface, simply because a database schema changed and the frontend was left guessing. When you are building and maintaining the entire architecture, relying on hope to sync your data isn't a sustainable strategy. That is why establishing strict, end-to-end type safety has become a non-negotiable part of my workflow. When your frontend and backend speak the exact same language, everything moves faster. Here is how that plays out in a modern stack: * **The Backend Contract:** Structuring an API with **NestJS** alongside a robust **SQL** database forces you to define your data rigidly. Whether I am using **PostgreSQL** for heavy production environments or spinning up **PGLite** for rapid local iteration, I know exactly what shape my data is in before it ever leaves the server. * **The Seamless Bridge:** By sharing those TypeScript interfaces across the stack, the gap between the server and the browser disappears. * **The Frontend Execution:** When **React** and **Next.js** catch data shape errors in the IDE before I even hit save, the development experience completely shifts. I can confidently design complex layouts using **Tailwind CSS** and **shadcn/ui**, knowing the props feeding those components are exactly what the interface expects. Type safety is rarely just about preventing bugs. It is about developer velocity. It gives you the confidence to refactor aggressively, update UI components, and scale features without the constant, lingering fear that you just broke an obscure page on the other side of the app. What is your current approach to keeping your backend and frontend types in sync? Are you using a monorepo structure to share types, or generating schemas dynamically? Let's talk architecture below. 👇 #TypeScript #FullStackDevelopment #Nextjs #NestJS #SoftwareEngineering #WebDevelopment #FrontendArchitecture
To view or add a comment, sign in
-
𝗜 𝗸𝗲𝗽𝘁 𝗿𝗮𝗻 𝗶𝗻𝘁𝗼 𝘁𝗵𝗶𝘀 𝗽𝗿𝗼𝗯𝗹𝗲𝗺 ⚠️ 𝗶𝗻 𝗲𝘃𝗲𝗿𝘆 𝗡𝗲𝘅𝘁.𝗷𝘀 𝗽𝗿𝗼𝗷𝗲𝗰𝘁. Different developers return API responses differently. One route returns { user } Another returns { success: true, data } Another returns { error: "Not found" } 🐛 And the frontend ends up guessing every time 😕 That’s where things start breaking 🤦♂️ 𝗧𝗵𝗲 𝗿𝗲𝗮𝗹 𝗽𝗿𝗼𝗯𝗹𝗲𝗺: No consistency. Frontend logic becomes messy Code becomes harder to maintain Team velocity slows down 𝗦𝗼 𝗜 𝗯𝘂𝗶𝗹𝘁 𝘀𝗼𝗺𝗲𝘁𝗵𝗶𝗻𝗴 𝘀𝗶𝗺𝗽𝗹𝗲 🛠️ 👉 https://lnkd.in/dKGXSCjC A small utility that keeps your API responses consistent across all routes. 𝗧𝗵𝗲 𝗶𝗱𝗲𝗮 𝗶𝘀 𝘀𝗶𝗺𝗽𝗹𝗲: Every response should have the same shape. No matter success or error. So now the frontend always knows: 👉 where the data is 👉 where the errors are 👉 what to expect No guessing. 𝗘𝘅𝗮𝗺𝗽𝗹𝗲: return ok({ data: user }); return notFound({ message: "User not found" }); return serverError(error); 𝗪𝗵𝘆 𝗶𝘁 𝗺𝗮𝘁𝘁𝗲𝗿𝘀: Consistency > cleverness Less confusion Less repeated logic Cleaner frontend code If you’ve worked on growing APIs, you’ve probably faced this. Would love to know how you handle response consistency 👇 #nextjs #typescript #webdevelopment #api #backend #fullstack
To view or add a comment, sign in
-
-
“Wait… did I just delete my entire backend?” 🤯 That’s exactly what it feels like using the latest features in Next.js. We’ve officially entered the era where your frontend framework IS your backend. 🔥 The game-changer: Server Actions No APIs. No controllers. No routes. Just write this 👇 async function createUser(formData) { "use server" await db.user.create({ data: formData }) } And call it directly from your UI. That’s it. You just built a backend endpoint… without building one. ⚡ Real Example (this blew my mind) Imagine a simple login/signup flow: Before: • Create API route /api/signup • Handle POST request • Validate data • Connect DB • Return response • Call API from frontend Now with Next.js: async function signup(data) { "use server" await db.user.create({ data }) } <form action={signup}> <input name="email" /> <button>Sign up</button> </form> No fetch. No API layer. No headache. 🧠 Why this is a big deal • Less code → faster shipping • No context switching between frontend/backend • Built-in security (runs on server only) • Direct DB calls • Works perfectly with streaming + React Server Components 🚀 Bonus: It scales globally by default Deploy on Vercel → your “backend” runs across the globe (Edge + Serverless). ⚠️ But don’t get carried away This doesn’t kill backend engineering. You’ll still need: • Background jobs • Complex business logic • Microservices at scale 💡 The real shift We’re moving from: 👉 “Frontend + Backend” to 👉 “One framework that handles both” And honestly… it’s addictive. Curious — would you trust your entire backend to Next.js? 👀 #NextJS #React #FullStack #WebDev #JavaScript #StartupTech #BuildInPublic #Techtrends
To view or add a comment, sign in
-
Bad API design creates frontend complexity. Not the other way around. Here’s what I’ve seen 👇 Problem: → Inconsistent response structure → Over-fetching / under-fetching → Poor naming Frontend impact: ❌ Complex mapping logic ❌ Extra state handling ❌ More bugs What works: ✔ Consistent API contracts ✔ Predictable data shape ✔ Proper versioning Key insight: Good frontend depends on good backend design. They are not separate concerns. #API #Backend #Frontend #SoftwareEngineering #SystemDesign #JavaScript #Engineering #WebDevelopment #Tech
To view or add a comment, sign in
-
🚫 Stop treating Next.js and NestJS as competitors This confusion is everywhere — and it leads to poor system design. Here’s the reality 👇 🔷 **Next.js** Built for the **frontend layer** • React-based framework • SSR / SSG / ISR for performance • SEO-friendly apps • Handles UI + light backend (API routes) 🔶 **NestJS** Built for the **backend layer** • Node.js framework for scalable APIs • REST / GraphQL support • Clean architecture (Controllers, Services, Modules) • Handles business logic, auth, data flow --- 💡 **The Real Difference** 👉 Next.js = What users see 👉 NestJS = What powers everything behind the scenes --- ⚡ **When to use what?** Use Next.js when: • You’re building UI-heavy apps • You need SEO (web apps, SaaS, dashboards) Use NestJS when: • You’re building scalable backend systems • You need structured architecture & complex logic --- 🔥 **Best Stack for Production** Next.js + NestJS Frontend + Backend = Fast ⚡ Scalable 📈 Maintainable 🧠 --- At **SKN Software Labs**, this is our go-to stack for building real-world, high-performance applications. 💬 What’s your stack preference — monolithic or structured backend? #NextJS #NestJS #FullStackDevelopment #WebDevelopment #JavaScript #NodeJS #ReactJS #BackendDevelopment #FrontendDevelopment #SoftwareArchitecture #TechStack #Developers #CleanCode #SKNSoftwareLabs
To view or add a comment, sign in
-
-
🚀 𝐃𝐚𝐲 2/30 – 𝐍𝐨𝐝𝐞.𝐣𝐬 𝐒𝐞𝐫𝐢𝐞𝐬: 𝐄𝐯𝐞𝐧𝐭 𝐋𝐨𝐨𝐩 (𝐓𝐡𝐞 𝐇𝐞𝐚𝐫𝐭 𝐨𝐟 𝐍𝐨𝐝𝐞.𝐣𝐬) If you understand this, you understand Node.js. Most developers say Node.js is single-threaded… 👉 But still wonder: “How does it handle multiple requests?” The answer = 𝐄𝐯𝐞𝐧𝐭 𝐋𝐨𝐨𝐩 🔁 💡 𝐖𝐡𝐚𝐭 𝐢𝐬 𝐄𝐯𝐞𝐧𝐭 𝐋𝐨𝐨𝐩? It’s a mechanism that: ➡ Continuously checks if tasks are completed ➡ Moves completed tasks to execution ➡ Ensures Node.js doesn’t block 🧠 𝐇𝐨𝐰 𝐢𝐭 𝐚𝐜𝐭𝐮𝐚𝐥𝐥𝐲 𝐰𝐨𝐫𝐤𝐬 (𝐬𝐢𝐦𝐩𝐥𝐢𝐟𝐢𝐞𝐝): Call Stack → Executes code Web APIs / System → Handles async tasks (I/O, timers, API calls) Callback Queue → Stores completed tasks Event Loop → Pushes them back to stack when ready 🔁 𝐑𝐞𝐚𝐥-𝐰𝐨𝐫𝐥𝐝 𝐟𝐥𝐨𝐰: 𝘤𝘰𝘯𝘴𝘰𝘭𝘦.𝘭𝘰𝘨("𝘚𝘵𝘢𝘳𝘵"); 𝘴𝘦𝘵𝘛𝘪𝘮𝘦𝘰𝘶𝘵(() => { 𝘤𝘰𝘯𝘴𝘰𝘭𝘦.𝘭𝘰𝘨("𝘛𝘪𝘮𝘦𝘰𝘶𝘵 𝘥𝘰𝘯𝘦"); }, 0); 𝘤𝘰𝘯𝘴𝘰𝘭𝘦.𝘭𝘰𝘨("𝘌𝘯𝘥"); 👉 Output: Start End Timeout done ❗ Even with 0ms, it waits — because Event Loop prioritizes the call stack first. ⚡ Why this matters in real projects Let’s say: 100 users hit your API Each API calls DB + external service Without event loop: ❌ Requests block each other With Node.js: ✅ Requests are handled asynchronously ✅ System stays responsive 🔥 From my experience: In production systems, long-running operations (like file processing, invoice parsing, etc.) should NOT sit in the event loop. 👉 We offloaded them to async queues (Service Bus / workers) Why? ✔ Keeps event loop free ✔ Avoids blocking requests ✔ Improves scalability ⚠️ Common mistake developers make: while(true) { // heavy computation } ❌ This blocks the event loop → entire app freezes ✅ Takeaway: Event Loop is powerful, but: ✔ Keep it light ✔ Offload heavy tasks ✔ Design async-first systems 📌 Tomorrow (Day 3): Callbacks → Why they caused problems (Callback Hell) #NodeJS #EventLoop #JavaScript #BackendDevelopment #SystemDesign #FullStack
To view or add a comment, sign in
-
-
Your frontend and your backend are speaking two different languages. And it's costing you hours of debugging every single week. Stop "hoping" your API data is correct. In most Next.js projects, we treat the backend response like a promise that never breaks. We define an interface, fetch the data, and pray the schema hasn't changed. Then production happens. • A field name changes. • A required string becomes null. • A number becomes a string. Your UI crashes, your logs blow up, and you spend 3 hours hunting for a "Type Error" that TypeScript couldn't catch at build time. The "Senior" Architecture: 1. Zero Trust Policy: Never assume the API is right. 2. Schema Validation: Use Zod to parse every single incoming payload. 3. Fail Gracefully: If the data is wrong, handle it at the boundary—don't let it poison your entire component tree. The Reality: Type-safety is a lie if it only exists in your IDE. If your data isn't validated at runtime, your "Senior" title is just a label. Are you still manually checking if data?.user?.profile exists, or are you actually validating your engine? 👇 #NextJS #TypeScript #CleanCode #SoftwareArchitecture #FullStackDevelopment #SaaS #WebDev
To view or add a comment, sign in
-
-
🚀 Day 5 — APIs & Fetch (Connecting Frontend to Backend) This is where everything starts making sense. Frontend alone is not enough. Backend alone is not enough. 👉 APIs connect both. Today I learned how to: ✔ Send requests using fetch() ✔ Handle JSON responses ✔ Display real data on the UI And one key realization: APIs are the bridge between ideas and real applications. Next → Handling forms & user input If you're serious about backend or full stack— this is a must-know concept. #day5 #api #javascript #backend #webdevelopment #developers
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development