Next Js

Next Js

framework for building fast, scalable, and SEO-friendly web applications

next js

مقالات

Authorization in Next.js – Optimistic Checks, Data Access Layer, and Role-Based Control

Once a user is authenticated, authorization in Next.js determines what routes and data they can access. This article explains optimistic and secure checks, using Proxy for early redirects, building a centralized Data Access Layer (DAL), applying Data Transfer Objects (DTOs), and rendering components based on user roles in Server Components.

/persian/article-fa/nextjs-authorization-access-control-user-role-dal

Securing Server Actions and Route Handlers in Next.js – Role Checks, Session Validation, and Context Limitations

In Next.js, Server Actions and Route Handlers must be treated with the same security considerations as public API endpoints. This article explains how to verify user roles before mutations, enforce access control in Route Handlers, understand the limitations of context providers in Server Components, and explore recommended libraries for secure authentication and session management.

/persian/article-fa/nextjs-security-server-actions-route-handlers-role-checks-context

Webhooks, Callback URLs, and Security in Next.js – Route Handlers, Proxy, and Access Control

Next.js allows you to receive external events via webhooks and callback URLs. This article explains how to build Route Handlers to process events, perform redirects, proxy requests, and implement robust security practices including header control, rate limiting, payload validation, and access protection.

/persian/article-fa/nextjs-webhooks-callbacks-proxy-security-handlers

How to use Next.js as a backend for your frontend Next.js

Next.js supports the Backend for Frontend (BFF) pattern, allowing you to create public endpoints that handle HTTP requests and return any content type. This article explains how to use Route Handlers, Proxy, and API Routes to build a secure and flexible backend layer for your frontend, including examples for data transformation, request validation, and content delivery.

/persian/article-fa/nextjs-backend-for-frontend-route-handlers-data-proxy

Caching in Next.js – Optimizing Performance with Request, Data, and Route Memory

Next.js uses intelligent caching to boost performance and reduce server costs. This article explores the different caching mechanisms in Next.js, how rendering strategies affect them, and how to control caching behavior using built-in APIs like fetch, revalidatePath, and router.prefetch..

/persian/article-fa/nextjs-caching-request-data-route-revalidation

Configuring CI Build Caching for Next.js – Speeding Up Builds with .next/cache

Next.js stores build cache in .next/cache to improve performance and reduce build time. To benefit from this in CI environments, your workflow must persist this cache between builds. This article walks through caching setup for popular CI providers including GitHub Actions, GitLab, Jenkins, Vercel, and more.

/persian/article-fa/nextjs-ci-build-cache-configuration-performance

Setting a Content Security Policy (CSP) in Next.js – Nonces, Proxy Headers, and Dynamic Rendering

Content Security Policy (CSP) protects your Next.js application from XSS, clickjacking, and injection attacks. This article explains how to configure CSP headers using Proxy, generate nonces for inline script safety, and enforce dynamic rendering to support nonce-based security.

/persian/article-fa/nextjs-content-security-policy-csp-nonce-dynamic-rendering

Configuring CSP Without Nonces in Next.js – Using Subresource Integrity and Secure Static Rendering

If your application doesn’t require nonces, you can configure Content Security Policy (CSP) directly in next.config.js.. Next.js also supports experimental Subresource Integrity (SRI), allowing strict CSP enforcement while preserving static rendering and CDN caching. This article explains how to set CSP headers, enable SRI, handle development vs production differences, and safely integrate third-party scripts.

/persian/article-fa/nextjs-csp-without-nonce-subresource-integrity-static-security

Using CSS-in-JS in Next.js – Style Registries, Streaming Support, and Concurrent Rendering

CSS-in-JS libraries allow you to define styles directly inside your React components. In Next.js, using these libraries with Server Components and streaming requires support for React 18’s concurrent rendering. This article explains how to configure styled-jsx and styled-components using style registries and the useServerInsertedHTML hook.

/persian/article-fa/css-in-js-nextjs-style-registry-server-components-streaming

Setting Up a Custom Server in Next.js – Request Handling, Routing Control, and Performance Considerations

Next.js includes a built-in server that runs with next start. In rare cases, you may need a custom server to handle advanced routing or request logic. This article explains how to build a custom server using Node.js, configure your scripts, and understand the performance trade-offs and limitations of standalone mode.

/persian/article-fa/nextjs-custom-server-routing-http-performance

Thinking About Data Security in Next.js – Access Layers, Server Components, and Preventing Data Leakage

React Server Components in Next.js improve performance but shift how and where data is accessed. This article explores three recommended data-fetching strategies, how to design a secure Data Access Layer (DAL), how to prevent sensitive data from leaking to the client, and how to use protective tools like taint and server-only modules.

/persian/article-fa/nextjs-data-security-access-layer-server-components-leak-prevention

Mutating Data Securely in Next.js – Server Actions, Input Validation, and CSRF Protection

Next.js uses Server Actions to handle data mutations like form submissions, database updates, and user logout. This article explains how Server Actions work, their built-in security features, how to validate client input, manage encryption keys, prevent CSRF attacks, and avoid side effects during rendering. It also includes auditing tips for secure Next.js applications.

/persian/article-fa/nextjs-mutation-server-actions-security-validation-csrf
Next Js | دکتر شاهین صیامی