Computer Science

Computer Science

In this section, we explore the world of programming, algorithms, networks, and infrastructure

ProgrammingAlgorithmsComputer NetworksTechnologyInfrastructureSoftware EngineeringHardware Engineering

Related Categories

Featured Articles

proxy.ts in Next.js — The Silent Guardian at the Edge

The proxy.ts file in Next.js replaces middleware.ts and acts as an edge-level gatekeeper before your app renders. It can rewrite or redirect routes, set headers and cookies, block access, and run background tasks. This article explains how to use proxy.ts, define precise matchers, and implement real-world scenarios like authentication, A/B testing, CORS, and geo-based redirects.

/article/nextjs-proxy-edge-redirect-auth-cors-security-headers

The public Folder in Next.js — Serving Static Files with Direct Paths

The public folder in Next.js is used to serve static files like images, fonts, and text documents. Files placed in this folder are accessible via direct URLs and can be rendered in the browser without special imports. This article explains how to use the public folder, display images, and understand its caching behavior.

/article/nextjs-public-folder-static-assets-image-serving-cache-control

route.ts in Next.js — Building Custom APIs with Web Request and Response

Route Handlers in Next.js allow you to define custom request logic using Web APIs. With support for all major HTTP methods, cookies, headers, query parameters, dynamic segments, streaming, and webhooks, route.ts files offer a powerful way to build flexible, server-side functionality directly within your app.

/article/nextjs-route-handlers-api-methods-cookies-streaming-webhooks

template.tsx in Next.js — Resetting Client State with Unique Keys

The template.tsx file in Next.js behaves like a layout but remounts on every navigation due to its unique key. Unlike layouts that persist across routes, templates reset the state of child Client Components, re-run effects like useEffect, and show Suspense fallbacks on every route change. This makes them ideal for input resets, effect resynchronization, and dynamic UI transitions.

/article/nextjs-template-component-remount-reset-client-state-navigation-key

unauthorized.tsx in Next.js — Custom 401 UI for Unauthenticated Access

The unauthorized.tsx file in Next.js is an experimental feature used to render a custom UI when the unauthorized() function is called during authentication. It allows you to display a login prompt or message for unauthenticated users, and automatically returns a 401 status code. This article explains how to use unauthorized.tsx to improve user experience during access control.

/article/nextjs-unauthorized-component-authentication-401-login-ui

favicon, icon, and apple-icon in Next.js — Setting App Icons with Files or Code

Next.js supports special conventions for setting app icons: favicon, icon, and apple-icon. These icons appear in browser tabs, mobile home screens, and search engine previews. You can define them using image files or generate them programmatically with ImageResponse. This article explains both approaches, valid file locations, metadata configuration, and how Next.js automatically injects the correct <head> tags.

/article/nextjs-favicon-icon-apple-icon-imageresponse-og-head-tags

manifest.json in Next.js — Defining App Metadata for Browsers

The manifest.json or manifest.webmanifest file in Next.js provides metadata about your application to browsers. It defines the app’s name, icons, colors, and display behavior, especially for Progressive Web Apps (PWAs). You can define it statically or generate it dynamically using manifest.ts.. This article explains both approaches, valid placement, and supported options.

/article/nextjs-manifest-json-webmanifest-pwa-metadata-icons

opengraph-image and twitter-image in Next.js — Generating Social Preview Images for Each Route

Next.js supports special conventions for generating social preview images using opengraph-image and twitter-image files. These images appear when your site is shared on platforms like Twitter, WhatsApp, or LinkedIn. You can define them using static image files or generate them dynamically with ImageResponse. This article explains both approaches, metadata configuration, and how to customize previews per route segment.

/article/nextjs-opengraph-twitter-image-social-preview-imageresponse-og-meta-tags

robots.txt in Next.js — Controlling Search Engine Access to Your Site

The robots.txt file in Next.js defines which parts of your site search engine crawlers can access. You can create it as a static file or generate it dynamically using a special Route Handler. You can also customize rules for specific bots like Googlebot or Bingbot. This article explains how to define the file, its structure, and advanced configuration options.

/article/nextjs-robots-txt-metadata-route-crawler-access-sitemap

sitemap.xml in Next.js — Generating SEO-Friendly Sitemaps for Crawlers

Next.js supports sitemap.xml through both static files and dynamic route handlers. These sitemaps help search engine crawlers index your site efficiently by listing URLs, last modified dates, priorities, and change frequencies. You can also generate image, video, and localized sitemaps, or split large sitemaps into multiple files. This article explains all supported formats and strategies.

/article/nextjs-sitemap-xml-metadata-route-dynamic-localized-image-video

after in Next.js — Scheduling Post-Response Tasks for Logging and Analytics

The after function in Next.js lets you schedule tasks to run after a response or prerender is completed. It’s ideal for non-blocking side effects like logging, analytics, or background operations. You can use it in Server Components, Server Actions, Route Handlers, and Proxy. It doesn’t make your route dynamic and runs even if the response fails. This article explains how to use after, its limitations, and examples with request APIs.

/article/nextjs-after-callback-post-response-logging-analytics-server-components

cacheLife in Next.js — Controlling Cache Duration for Components and Functions

The cacheLife function in Next.js lets you define how long a component or function should remain cached. It works alongside the use cache directive and must be called within the same scope. You can use preset profiles like seconds, days, or max, or define custom profiles in next.config.ts.. This article explains how cacheLife works, the difference between stale, revalidate, and expire, and how to apply it across your app.

/article/nextjs-cacheLife-component-function-cache-strategy-stale-revalidate-expire
Computer Science | Dr. Shahin Siami