logo Online Learner
  • Home
  • Learning Paths
  • Development
    Frontend Development Backend Development
  • Study Notes
  • Free Resume Builder
  • About Us
  • Contact Us
  • Login
  • Sign Up
  1. Learning Paths
  2. TypeScript Tutorial
  3. TypeScript with React

TypeScript with React

TypeScript with React is a common pairing in modern web development. React builds the user interface, and TypeScript checks that your props, state, and event handlers use the right types. This catches bugs before you open the browser. In real projects, typed components make refactoring safer and give strong autocomplete in the editor.

This tutorial shows you how to create a React + TypeScript project with Vite, type component props, handle optional and default props, type children, useState and useRef, handle events like ChangeEvent and MouseEvent, type fetched data, and build a small generic list component. Each example is complete and compiles under strict mode.

How Do You Create a React + TypeScript Project?

The fastest way to start is with Vite, a modern build tool. You can use npm create vite@latest to generate a project. Pick the react-ts template and Vite sets up React, TypeScript, and a tsconfig.json with strict mode ready.

Here is the setup:

npm create vite@latest my-app -- --template react-ts
cd my-app
npm install
npm run dev

You should see a starter page at localhost:5173. Open src/App.tsx and you can start writing typed components.

How Do You Type React Component Props?

A prop is data passed into a component from its parent. In TypeScript, you define an interface that describes each prop's type. The component function receives an object of that shape, so the compiler checks every prop at every call site.

interface GreetingProps {
  name: string;
  age: number;
}

function Greeting({ name, age }: GreetingProps) {
  return <p>{name} is {age} years old.</p>;
}

// Usage in App:
// <Greeting name="Riya" age={28} />

// Output in the browser: Riya is 28 years old.

How it works: The GreetingProps interface declares name and age. The component destructures them. If you call <Greeting name="Riya" /> without age, the compiler reports a missing prop error. If you pass age="28" as a string, the compiler rejects it too. This is the core pattern for every typed component.

How Do Optional and Default Props Work?

An optional prop uses ? in the interface and may be missing at the call site. A default prop provides a fallback value using a destructuring default. Optional props get undefined in their type, so a default handles the missing case cleanly.

interface ButtonProps {
  label: string;
  variant?: "primary" | "secondary";
  disabled?: boolean;
}

function Button({ label, variant = "primary", disabled = false }: ButtonProps) {
  return (
    <button className={variant} disabled={disabled}>
      {label}
    </button>
  );
}

// <Button label="Save" /> uses both defaults
// <Button label="Cancel" variant="secondary" disabled />

// Output: a styled button with the given label

How it works: variant and disabled are optional, so callers may skip them. The destructuring defaults "primary" and false fill in when the prop is undefined. The variant type is a literal union, so passing "danger" is a compile error. This gives you a small, safe API for each component.

How Do You Type children?

The children prop is the content between the opening and closing tags. Its type is usually React.ReactNode, which accepts strings, numbers, JSX elements, arrays, and null. Use ReactNode for flexible wrappers like layouts and cards.

import type { ReactNode } from "react";

interface CardProps {
  title: string;
  children: ReactNode;
}

function Card({ title, children }: CardProps) {
  return (
    <div className="card">
      <h3>{title}</h3>
      {children}
    </div>
  );
}

// <Card title="Welcome"><p>Hello</p></Card>

// Output: a card with the title and the paragraph inside

How it works: The children prop is typed as ReactNode, so the component accepts almost any renderable content. If you typed it as string, the JSX child <p>Hello</p> would fail. Use ReactNode for generic wrappers and a narrower type when you need specific children.

How Do You Type useState and useRef?

useState is a hook, a function that adds state to a function component. TypeScript infers the state type from the initial value. When the initial value is null or a union, pass the type explicitly with <Type>. useRef holds a mutable reference, and its type is useRef<Type>(initial).

import { useState, useRef } from "react";

interface User {
  id: number;
  name: string;
}

function UserPanel() {
  const [user, setUser] = useState<User | null>(null);
  const inputRef = useRef<HTMLInputElement>(null);

  function loadUser() {
    setUser({ id: 1, name: "Riya" });
  }

  function focusInput() {
    inputRef.current?.focus();
  }

  return (
    <div>
      <input ref={inputRef} />
      <button onClick={focusInput}>Focus</button>
      <button onClick={loadUser}>Load</button>
      <p>{user ? user.name : "No user"}</p>
    </div>
  );
}

// Output initially: "No user"
// After clicking Load: "Riya"

How it works: useState<User | null>(null) says the state is a User or null. That lets the component render a fallback before data arrives. useRef<HTMLInputElement>(null) says the ref will point to an input element. inputRef.current?.focus() uses optional chaining because current may be null before the element mounts. Without the explicit type on useRef, current would be null forever, and .focus() would fail.

How Do You Type Event Handlers?

Event handlers like onChange and onClick receive event objects. TypeScript types them with React.ChangeEvent<HTMLInputElement> and React.MouseEvent<HTMLButtonElement>. The generic parameter is the element type, which gives you accurate properties like value or currentTarget.

import { useState } from "react";
import type { ChangeEvent, MouseEvent } from "react";

function SearchForm() {
  const [query, setQuery] = useState("");

  function handleChange(event: ChangeEvent<HTMLInputElement>) {
    setQuery(event.target.value);
  }

  function handleClick(event: MouseEvent<HTMLButtonElement>) {
    event.preventDefault();
    console.log(`Searching for: ${query}`);
  }

  return (
    <form>
      <input value={query} onChange={handleChange} />
      <button onClick={handleClick}>Search</button>
    </form>
  );
}

// Output in the console when clicking: Searching for: <query>

How it works: ChangeEvent<HTMLInputElement> types the event so event.target.value is a string. If you typed the parameter as a plain Event, the compiler would not know about target.value. MouseEvent<HTMLButtonElement> gives access to button-specific properties and preventDefault. Use the correct generic so the event object is useful inside the handler.

How Do You Type a Fetch Result?

When you fetch data from an API, the response starts as unknown. You should validate it or cast it after checking the shape. Then useState<User | null> stores the parsed result and renders it safely.

import { useState, useEffect } from "react";

interface User {
  id: number;
  name: string;
}

function UserLoader() {
  const [user, setUser] = useState<User | null>(null);
  const [error, setError] = useState<string | null>(null);

  useEffect(() => {
    async function load() {
      try {
        const response = await fetch("/api/user/1");
        const data: unknown = await response.json();
        if (typeof data === "object" && data !== null && "name" in data) {
          setUser(data as User);
        } else {
          setError("Invalid response");
        }
      } catch {
        setError("Network error");
      }
    }
    load();
  }, []);

  if (error) return <p>{error}</p>;
  return <p>{user ? user.name : "Loading..."}</p>;
}

// Output: "Loading..." then the user name when data arrives

How it works: response.json() returns any, so we store it as unknown to keep safety. The check verifies the object has a name field before casting. useState<User | null> models the loading state. useState<string | null> models the error. The component renders the right branch based on those states. This is the standard fetch pattern in typed React code.

How Do You Build a Generic List Component?

A generic component takes a type parameter so it can render any item type. Write <T,> with a trailing comma in .tsx files so the parser does not confuse it with JSX. Then type the items array and the renderItem callback with T.

interface ListProps<T> {
  items: T[];
  renderItem: (item: T) => React.ReactNode;
}

function List<T,>({ items, renderItem }: ListProps<T>) {
  return (
    <ul>
      {items.map((item, index) => (
        <li key={index}>{renderItem(item)}</li>
      ))}
    </ul>
  );
}

// <List items={["a", "b"]} renderItem={(s) => <b>{s}</b>} />
// <List items={[1, 2]} renderItem={(n) => <i>{n}</i>} />

// Output: a list of rendered items

How it works: The List component is generic over T. When you pass items={["a", "b"]}, T becomes string, so renderItem receives a string. When you pass numbers, T is number. The trailing comma after T is required in .tsx files to tell the parser this is a type parameter, not a JSX tag. This pattern works for tables, dropdowns, and any repeated UI.

React.FC vs Plain Function Components: Which Should You Use?

Feature React.FC Plain function
Types children automatically Yes (older versions) No, type it yourself
Works with generics Awkward Yes, straightforward
Default props clarity Less clear Clear with destructuring defaults
Recommended today Not preferred Yes

The recommendation is to use a plain function component with a props interface. React.FC is still supported, but it adds an implicit children type that can hide mistakes, and it complicates generic components. Plain functions are simpler and align with modern React guidance. You can learn more about interfaces in the TypeScript Interfaces tutorial.

Common Mistakes and Best Practices

  • Typing event handlers with any. This loses the element type and hides bugs like reading value from a button. Always use ChangeEvent<HTMLInputElement>, MouseEvent<HTMLButtonElement>, or the correct generic for the target element.
  • Forgetting the explicit type on useState when starting with null. useState(null) infers null and never allows a user object. Write useState<User | null>(null) so the setter accepts a User.
  • Using React.FC with generics. React.FC does not compose well with type parameters and can make the generic list component harder to write. Use a plain function and a props interface instead.
  • Missing the trailing comma in generic .tsx components. <T> is parsed as JSX in .tsx files. Write <T,> to make it a type parameter. This is a common and confusing syntax error.
  • Casting response.json() directly to a type. The data may not match, and the cast hides the problem. Store it as unknown, check the shape, then narrow or cast.

Real-World Example: Typed Button, Form Input, and User State

This example combines a typed Button component, a form input with ChangeEvent<HTMLInputElement>, and useState<User | null>.

import { useState } from "react";
import type { ChangeEvent } from "react";

interface User {
  id: number;
  name: string;
}

interface ButtonProps {
  label: string;
  onClick: () => void;
  variant?: "primary" | "secondary";
}

function Button({ label, onClick, variant = "primary" }: ButtonProps) {
  return (
    <button className={variant} onClick={onClick}>
      {label}
    </button>
  );
}

function UserForm() {
  const [name, setName] = useState("");
  const [user, setUser] = useState<User | null>(null);

  function handleChange(event: ChangeEvent<HTMLInputElement>) {
    setName(event.target.value);
  }

  function handleSave() {
    if (name.trim() === "") return;
    setUser({ id: Date.now(), name });
  }

  return (
    <div>
      <input value={name} onChange={handleChange} placeholder="Your name" />
      <Button label="Save" onClick={handleSave} />
      <Button label="Clear" variant="secondary" onClick={() => setName("")} />
      <p>{user ? `Saved: ${user.name}` : "No user saved"}</p>
    </div>
  );
}

// Output initially: "No user saved"
// After typing and clicking Save: "Saved: <name>"

How it works, line by line. The User interface models the saved data. ButtonProps types the button with a required label and onClick and an optional variant that defaults to "primary". Button renders a styled button and passes the click through. In UserForm, useState("") infers string for name, and useState<User | null>(null) models the saved user. The handleChange function uses ChangeEvent<HTMLInputElement> so event.target.value is a string. handleSave guards against empty input and creates a user with a timestamp ID. The JSX renders the input, two buttons, and the status line. The Clear button uses an inline arrow for a simple reset. Every prop and event is checked at compile time, so a wrong label type or a missing onClick is caught before the browser runs the code. The TypeScript Generics tutorial explains the type-parameter machinery behind the generic list component.

Summary

  • TypeScript with React adds type safety to props, state, events, and data, catching bugs before runtime.
  • Create a project with npm create vite@latest and the react-ts template to get strict TypeScript set up.
  • Type props with an interface; use ? for optional props and destructuring defaults for defaults.
  • Type children as ReactNode, and use useState<User | null> for nullable state.
  • Use ChangeEvent<HTMLInputElement> and MouseEvent<HTMLButtonElement> for accurate event types.
  • Generic components with <T,> handle any item type, and plain function components are preferred over React.FC.

Now that you can type React components, continue to the TypeScript with Node.js tutorial to learn how to build typed backends with Express and Node.

Frequently Asked Questions

Should I use React.FC for my components?

Most modern React teams do not. React.FC adds an implicit children type in older versions, complicates generics, and makes default props less clear. Use a plain function with a props interface and destructure the props. You can still type children explicitly as ReactNode when the component needs it.

How do I type useState when the initial value is null?

Pass the type explicitly: useState<User | null>(null). Without it, TypeScript infers null, and the setter only accepts null. The explicit union allows both null and User, so you can start empty and fill in data later. This is the standard pattern for fetched data.

Why do I need a trailing comma in <T,> for generic components?

In .tsx files, the parser treats <T> as the start of a JSX tag. Adding a trailing comma, <T,>, tells the parser this is a type parameter list, not JSX. Without it, you get a syntax error. This rule applies to arrow functions and function declarations in .tsx files.

How do I type an onClick handler?

Use MouseEvent<HTMLButtonElement> for a button click. Import the type from React: import type { MouseEvent } from "react". The generic parameter is the element the handler is attached to, which gives you correct properties like currentTarget. If you do not need the event, you can type the handler as () => void.

Can I use TypeScript with React without a build tool?

You can, but it is not practical for most projects. React uses JSX, which browsers do not understand, so a build step is needed to transform JSX and TypeScript into JavaScript. Vite, Next.js, and Create React App all handle this. Use one of them for a smooth setup.

Practice Exercises

Exercise 1 (Easy): Type a Button Component

Create a Button component with props label: string, onClick: () => void, and an optional disabled?: boolean. Render a button.

Show solution
interface ButtonProps {
  label: string;
  onClick: () => void;
  disabled?: boolean;
}

function Button({ label, onClick, disabled = false }: ButtonProps) {
  return (
    <button onClick={onClick} disabled={disabled}>
      {label}
    </button>
  );
}

// <Button label="Save" onClick={() => console.log("saved")} />
// <Button label="Cancel" onClick={() => {}} disabled />

// Output: a button with the given label and state

The props interface types each field, and the destructuring default sets disabled to false when omitted.

Exercise 2 (Easy): Type a ChangeEvent

Create an input component with useState("") and a handleChange typed as ChangeEvent<HTMLInputElement>. Print the typed value.

Show solution
import { useState } from "react";
import type { ChangeEvent } from "react";

function NameInput() {
  const [name, setName] = useState("");

  function handleChange(event: ChangeEvent<HTMLInputElement>) {
    setName(event.target.value);
  }

  return (
    <div>
      <input value={name} onChange={handleChange} />
      <p>{name}</p>
    </div>
  );
}

// Output: the paragraph mirrors what you type

The ChangeEvent<HTMLInputElement> type makes event.target.value a string, which matches the useState("") type.

Exercise 3 (Medium): useState with a Union Type

Create a component with useState<User | null>(null) where User has id and name. Add a button that sets a user and a paragraph that shows the name or "No user".

Show solution
import { useState } from "react";

interface User {
  id: number;
  name: string;
}

function UserPanel() {
  const [user, setUser] = useState<User | null>(null);

  return (
    <div>
      <button onClick={() => setUser({ id: 1, name: "Riya" })}>Load</button>
      <p>{user ? user.name : "No user"}</p>
    </div>
  );
}

// Output initially: "No user"
// After clicking Load: "Riya"

The union type lets the state start as null and later hold a User, which is the standard pattern for async data.

Exercise 4 (Challenge): Generic List Component

Create a generic List<T,> component with items: T[] and renderItem: (item: T) => React.ReactNode. Use it with a string array and a number array.

Show solution
import type { ReactNode } from "react";

interface ListProps<T> {
  items: T[];
  renderItem: (item: T) => ReactNode;
}

function List<T,>({ items, renderItem }: ListProps<T>) {
  return (
    <ul>
      {items.map((item, index) => (
        <li key={index}>{renderItem(item)}</li>
      ))}
    </ul>
  );
}

// <List items={["a", "b"]} renderItem={(s) => <b>{s}</b>} />
// <List items={[1, 2]} renderItem={(n) => <i>{n}</i>} />

// Output: two lists, one bold and one italic

The trailing comma in <T,> is required in .tsx files, and the generic keeps renderItem in sync with the item type.



Shaikh Abdul Shahid
Written by Shaikh Abdul Shahid

A Full-Stack Developer with experience in PHP, Laravel, JavaScript, and React.
Founder of Online Learner, sharing practical knowledge and programming tutorials.
Building and maintaining real-world web applications since 2017.

GitLab LinkedIn
X
0 likes
Your Feedback

Help us improve by sharing your thoughts.

IT and Digital Marketing
keyboard_arrow_left Previous
Next keyboard_arrow_right
Online Learner Logo

Online Learner helps developers master programming, database concepts, interview preparation, and real-world implementation through structured learning paths.

Quick Links

  • Frontend Development
  • Backend Development
  • Learning Paths
  • Notes
  • Free Resume Builder
  • Portfolio

Company

  • About Us
  • Contact Us
  • Terms & Conditions
  • Disclaimer

© 2023 - 2026 OnlineLearner.in | All Rights Reserved.

logo
  • code Frontend
  • storage Backend
  • live_help Interviews
  • work_outline PHP Frameworks
  • settings Routine Use
  • book Blogs
Frontend
  • HTML Tutorial
    • HTML Introduction
    • HTML Tags
    • HTML Elements
    • HTML Attributes
    • HTML Heading
    • HTML Paragraph
    • HTML Formatting
    • HTML Quotations
    • HTML Comments
    • HTML Styles
    • HTML Color
    • HTML CSS
    • HTML Images
    • HTML Favicon
    • HTML Links
    • HTML DIV
    • HTML Tables
    • HTML Table Size
    • HTML Table Head
    • Table Padding & Spa...
    • Table colspan rowspsn
    • HTML Table Styling
    • HTML Colgroup
    • HTML List
    • HTML Block & Inline
    • HTML Classes
    • HTML Id
    • HTML Iframes
    • HTML Head
    • HTML Layout
    • HTML Semantic Elements
    • HTML Style Guide
    • HTML Forms
    • HTML Form Attribute
    • HTML Form Element
    • HTML input type
    • HTML Computer code
    • HTML Entity
    • HTML Symbol
    • HTML Emojis
    • HTML Charset
    • HTML Input Form Att...
    • HTML URL Encoding
  • CSS Tutorial
    • CSS Introduction
    • CSS Syntax
    • CSS Selector
    • How To Add CSS
    • CSS Comments
    • CSS Colors
    • CSS Background color
    • CSS background-image
    • CSS Borders
    • CSS Margins
    • CSS Height, Width a...
    • CSS Box Model
    • CSS Outline
    • CSS Text
    • CSS Fonts
    • CSS Icon
    • CSS Links
    • CSS Tables
    • CSS Display
    • CSS Maximum Width
    • CSS Position
    • z-index Property
  • JavaScript Tutorial
    • What is JavaScript
    • JS Syntax
    • JS Variables
    • JS Data Types
    • JS Operators
    • JS Control Flow - IF
    • JS Control Flow - S...
    • JS Control Flow - Loop
    • JS Function
    • JS Object Methods
    • JS Anonymous Funct...
    • JS Recursive Function
    • JS Default Parameters
    • JS this Keyword
    • What is an Array in...
    • What are JavaScript...
    • Error Handling in J...
    • DOM Selection in Ja...
    • DOM Traversal in Ja...
    • Manipulating Elemen...
    • Event Handling in J...
    • JavaScript Event Li...
    • JavaScript Event Pr...
    • Form Handling in Ja...
    • Dynamic Styling in ...
    • JavaScript DOM Elem...
    • Window Object in Ja...
    • What is Local Storage?
    • Regular Expressions...
  • Jquery Tutorial
    • What is jQuery?
    • Benefits of using j...
    • Include jQuery
    • Selectors.
    • Methods.
    • The $ symbol and sh...
    • Selecting elements
    • Getting and setting...
    • Adding and removing...
    • Modifying CSS and c...
    • Binding and Unbindi...
    • Common events: clic...
    • Event delegation
    • Using .on() for dyn...
    • Showing and hiding ...
    • Fading elements in ...
    • Sliding elements up...
    • .animate()
    • Understanding AJAX
    • .ajax()
    • .load(), .get(), .p...
    • Handling responses ...
    • Parent
    • Chlid
    • Siblings
    • Filtering Elements
    • Using find
    • Selecting form elem...
    • Getting form values
    • Setting form values
    • Form validation
    • Handling form submi...
    • jQuery plugins
    • Sliders plugins
    • $.each()
    • $.trim()
    • $.extend()
    • Data attributes
    • Debugging jQuery code
  • Bootstrap 4
    • What is Bootstrap
    • Benefits of using
    • Setting up
    • Container
    • Row and Column
    • Grid Classes
    • Breakpoints
    • Offsetting Columns
    • Column Ordering
    • Basic Typography
    • Text Alignment
    • Text colors
    • Backgrounds
    • Display
    • Font Size Utilities
    • Buttons
    • Navs and Navbar
    • Forms
    • Cards
    • Alerts
    • Badges
    • Progress Bars
    • Margin
    • Padding
    • Sizing
    • Flexbox
    • Dropdowns
    • Modals
    • Tooltips
    • Popovers
    • Collapse
    • Carousel
    • Images
    • Tables
    • Jumbotron
    • Media Object
  • Git
    • Understanding Versi...
    • Download and Instal...
    • Git Configure
    • Git Initialize
    • Add Changes to Staging
    • Commit Changes
    • Branching
    • Merging
    • Remote Repository
    • Understanding Git C...
    • Stashing Changes
    • Viewing Commit History
    • Undoing Changes
  • Ajax Tutorial
    • Ajax Fundamentals
    • Ajax Working
    • XMLHttpRequest Fetch
    • Synchronous vs Asyn...
    • Ajax Advantages
    • Ajax Disadvantages
    • $.ajax() method
    • Ajax GET request
    • Ajax POST Request
    • Json Response
    • Ajax Errors
    • Ajax Form
  • React Tutorial
    • What is React? Begi...
    • React Environment S...
    • React Fundamentals:...
    • Functional vs Class...
    • Props in React Expl...
    • State and setState ...
    • React Event Handling
    • React Conditional R...
    • React Lists and Keys
    • Styling in React In...
    • Styling in React Us...
    • Styling in React Us...
    • Tailwind CSS with R...
    • Tailwind vs CSS Mod...
    • React Hooks
    • React useState Hook
    • React useEffect Hook
    • React useRef Hook
    • React useContext Hook
    • React useReducer Hook
    • Custom Hooks in React
    • React Router – In...
    • Installing React Ro...
    • React Router – Ro...
    • React Router – Ne...
    • React Router URL Pa...
    • React Router Protec...
    • React Router Redire...
    • State Management in...
    • Redux State Managem...
    • Redux Toolkit Expla...
    • Redux Toolkit vs Re...
    • Controlled vs Uncon...
    • Handling Form Input...
    • API Integration in ...
    • Axios in React – ...
    • Handling Loading an...
    • Async Await in Java...
    • Displaying API Data...
    • CRUD Operations in ...
    • React Performance O...
    • React Performance O...
  • Tailwind
    • Introduction to Tai...
    • Utility-First CSS E...
    • Tailwind CSS vs Boo...
    • When and Why to Use...
    • Real-World Use Case...
    • Tailwind CSS Instal...
    • Installing Tailwind...
    • Tailwind CSS with V...
    • Setting Up Tailwind...
    • Install Tailwind CS...
    • Tailwind CSS Colors...
    • Tailwind CSS Backgr...
    • Tailwind CSS Paddin...
    • Tailwind CSS Margin...
    • Tailwind CSS Width ...
    • Tailwind CSS Height...
    • Tailwind CSS Border...
    • Tailwind CSS Border...
    • Tailwind CSS Text S...
    • Tailwind CSS Box Sh...
    • Tailwind CSS Opacit...
    • Tailwind CSS Cursor...
    • Tailwind CSS Overfl...
    • Tailwind CSS Font S...
    • Tailwind CSS Font W...
    • Tailwind CSS Text A...
    • Tailwind CSS Line H...
    • Tailwind CSS Letter...
    • Tailwind CSS Text T...
    • How to Use Google F...
    • Flexbox with Tailwi...
    • Justify Content in ...
    • Align Items in Tail...
    • Flex Direction in T...
    • Gap in Tailwind CSS...
    • Flexbox with Tailwi...
    • Grid System in Tail...
    • Grid System in Tail...
    • Responsive Design i...
    • Positioning & Z-Ind...
    • Background Colors i...
    • Background Images i...
    • Gradients in Tailwi...
    • Image Object-Fit in...
    • Image Overlay Effec...
    • Buttons in Tailwind...
    • Hover & Focus State...
    • Buttons and Forms i...
    • Cards and Sections ...
    • Navbar and Footer D...
  • TypeScript Tutorial
    • TypeScript Introduc...
    • TypeScript Installa...
    • First TypeScript Pr...
    • TypeScript Basic Types
    • Type Inference and ...
    • TypeScript Arrays a...
    • TypeScript Enums
    • TypeScript Any, Unk...
    • TypeScript Interfaces
    • Type Aliases and Un...
    • Intersection Types
    • Literal Types
    • Functions in TypeSc...
    • Classes in TypeScript
    • Access Modifiers an...
    • Abstract Classes
    • TypeScript Generics
    • TypeScript Utility ...
    • Type Guards and Nar...
    • Modules and Namespaces
    • TypeScript Decorators
    • TypeScript with React
    • TypeScript with Nod...
Backend
  • PHP Tutorial
    • PHP Introduction
    • PHP Installation
    • PHP Syntax
    • PHP Comments
    • PHP Variable
    • PHP Echo
    • PHP Data Types
    • PHP Strings
    • PHP Constant
    • PHP Maths
    • PHP Number
    • PHP Operators
    • PHP if else & if el...
    • PHP Switch
    • PHP Loops
    • PHP Functions
    • PHP Array
    • PHP OOps
    • PHP Class & Object
    • PHP Constructor
    • PHP Destructor
    • PHP Access Modfiers
    • PHP Inheritance
    • PHP Final Keyword
    • PHP Class Constant
    • PHP Abstract Class
    • PHP Superglobals
    • PHP Regular Expression
    • PHP Interfaces
    • PHP Static Method
    • PHP Static Properties
    • PHP Namespace
    • PHP Iterable
    • PHP Form Introduction
    • PHP Form Validation
    • PHP Complete Form
    • PHP Date and Time
    • PHP Include Files
    • PHP - Files & I/O
    • File Upload
    • PHP Cookies
    • PHP SESSION
    • PHP Filters
    • PHP Callback Functions
    • PHP JSON
    • PHP AND Exceptions
    • PHP Connect database
  • PHP Functions
    • strlen
    • strtoupper
    • strtolower
    • ucfirst
    • ucwords
    • substr
    • str_replace
    • strpos
    • trim in php
    • explode
    • implode
    • count in php
    • array_merge
    • array_push
    • array_pop
    • array_shift
    • array_unshift
    • in_array
    • array_keys
    • array_values
    • array_filter
    • array_map
    • sort
    • asort
    • ksort
    • abs
    • round
    • ceil
    • floor
    • rand
    • mt_rand
    • max
    • min
    • pow
    • sqrt
    • date
    • time
    • strtotime
    • mktime
    • date_diff
    • getdate
    • fopen
    • fread
    • fwrite
    • fclose
    • file_get_contents
    • file_put_contents
    • file_exists
    • unlink
    • filesize
    • is_readable
    • is_writable
    • urlencode
    • urldecode
    • parse_url
    • http_build_query
    • isset
    • empty
    • is_numeric
    • is_array
    • is_string
    • filter_var
    • htmlspecialchars
    • md5
    • sha1
    • password_hash
    • password_verify
    • die
    • exit
    • var_dump
    • print_r
    • include
    • require
    • json_encode
    • json_decode
    • sleep
  • PHP and MySQL Functions
    • mysqli_connect
    • mysqli_select_db
    • mysqli_query
    • mysqli_prepare
    • mysqli_stmt_execute
    • mysqli_multi_query
    • mysqli_fetch_assoc
    • mysqli_fetch_array
    • mysqli_fetch_row
    • mysqli_fetch_object
    • mysqli_num_rows
    • mysqli_real_escape_...
    • mysqli_insert_id
    • mysqli_affected_rows
    • mysqli_error
    • mysqli_close
    • mysqli_commit
    • mysqli_rollback
  • Python Tutorial
    • What is Python?
    • Install Python on W...
    • Install Python on L...
    • Install Python on m...
    • IDE Setup
    • Python syntax
    • Python Comments
    • Python Indentation
    • Python Variables
    • Python Data Types
    • Python Numeric
    • Python Boolean
    • Python String
    • Python List
    • Python Tuple
    • Python Range
    • Python Dictionary
    • Python Arithmetic O...
    • Python Assignment O...
    • Python Comparison O...
    • Python Logical Oper...
    • Python Bitwise Oper...
    • Python if condition
    • Python if else cond...
    • Python For Loop
    • Python While Loop
    • Python break, conti...
  • MYSQL
    • SQL Introduction
    • Syntax
    • Select statement
    • Select Distinct
    • WHERE Clause
    • Order By
    • SQL AND Operator
    • SQL OR Operator
    • SQL NOT Operator
    • SQL LIKE
    • SQL IN
    • SQL BETWEEN
    • SQL INSERT INTO
    • SQL NULL Values
    • SQL UPDATE
    • SQL DELETE
    • SQL TOP, LIMIT, FET...
    • SQL MIN() and MAX()...
    • SQL COUNT() Function
    • SQL SUM()
    • SQL AVG()
    • SQL Aliases
    • SQL JOIN
    • SQL INNER JOIN
    • SQL LEFT JOIN
    • SQL RIGHT JOIN
    • SQL FULL OUTER JOIN
    • SQL Self Join
    • SQL UNION
    • SQL GROUP BY
    • SQL HAVING
    • SQL EXISTS
    • SQL ANY and ALL
    • SQL SELECT INTO
    • SQL INSERT INTO SELECT
    • SQL CASE
    • SQL NULL Functions
    • SQL Stored Procedures
    • SQL Comments
    • SQL Operators
    • SQL CREATE DATABASE
    • SQL DROP DATABASE
    • SQL BACKUP DATABASE
    • SQL CREATE TABLE
    • SQL DROP TABLE
    • SQL ALTER TABLE
    • SQL Constraints
    • SQL NOT NULL
    • SQL UNIQUE Constraint
    • SQL PRIMARY KEY
    • SQL FOREIGN KEY
    • SQL CHECK Constraint
    • SQL CREATE INDEX
    • SQL AUTO INCREMENT
    • SQL Dates
    • SQL Views
    • SQL Injection
    • SQL Hosting
    • SQL Data Types
  • Node Js
    • What is Node.js?
    • Why use Node.js?
    • Installing Node.js
    • First Node.js progr...
    • Event Loop
    • Understanding npm
    • What are Modules?
    • fs (File System)
    • Http Module
    • Path Module
    • Creating custom mod...
    • Exporting and impor...
    • Setting up a basic ...
    • Handling requests a...
    • Serving HTML
    • Serving CSS
    • Serving JavaScript
  • Python MySQL
    • Database Connection
    • Table Creation
    • Insert Query
    • Select Query
    • Update Query
    • Delete Query
    • Where Clause Query
    • Limit Clause Query
    • Join Tables
    • Order By Query
    • Group By Query
    • Aggregate Functions
    • Parameterized Query
  • Java Tutorials
    • Java Introduction
    • Java Installation
    • Java Syntax
    • Java Comments
    • Java Variables
    • Java DataTypes
    • Java Operators
    • Java Conditionals
    • Java Looping
    • Java Arrays
    • Java Methods
    • Java Classes
    • Java Objects
    • Java Constructors
    • Java Inheritance
    • Java Polymorphism
    • Java Encapsulation
    • Java Abstraction
    • Java Exception
    • Java Interfaces
    • Java File Handling
    • Java Threads
    • Java Access Modifiers
    • Java Static Keyword
    • Java Final Keyword
    • Java Nested Class
    • Java Synchronization
  • Docker
    • Introduction to Docker
    • Installing Docker
    • Docker Architecture
    • Docker Images
    • Docker Containers
    • Dockerfile Basics
    • Docker Volumes
    • Docker Networking
    • Docker Compose
    • Docker Hub & Registry
    • Multi-Stage Builds
    • Docker with Nginx
    • Docker with MySQL
    • Docker with PHP & L...
    • Docker Environment ...
    • Docker Logs & Debug...
    • Docker Security Bes...
    • Docker Swarm Basics
    • Docker vs Virtual M...
    • Real World Docker P...
Interviews
  • PHP Interviews
    • What is PHP?
    • What does PHP stand...
    • PHP Advantages
    • Difference between ...
    • Start a PHP script?
    • Commenting in PHP
    • Variable in PHP
    • Different types of ...
    • Different types of ...
    • Array in PHP
    • Difference between ...
    • Retrieve data from ...
    • PHP handle errors
    • Sessions in PHP
    • PHP Cookie
    • What are the main f...
    • What are the differ...
    • What are the differ...
  • Java Interview Questions
    • Java Basics – Wha...
    • What is the differe...
    • What are the OOP co...
    • Why is the main met...
    • What are the differ...
    • What is the differe...
    • What is Method Over...
    • What is the Differe...
    • What is the Constru...
    • What are the Access...
    • What is the this Ke...
    • What is the super K...
    • What is the static ...
    • What is the final K...
    • What is Exception H...
    • What are Checked an...
    • What is the Differe...
    • What are Multithrea...
    • What is the Java Co...
    • What is the Differe...
    • What is the Differe...
    • What is the Differe...
    • What is the Differe...
    • How Does HashMap Wo...
    • What is the Differe...
    • What is the Differe...
    • What is the String ...
    • What is the Differe...
    • What is Garbage Col...
    • What is the Differe...
    • What is a Lambda Ex...
    • What is the Stream ...
    • What are Optional C...
    • What is the Differe...
    • What are the Key Fe...
    • What is the Record ...
  • React Interviews
    • What is React.js
    • Help In Interviews
    • Features of React
    • What is JSX
    • React's Virtual DOM
    • State and Props
    • React handle data b...
    • React Component
    • setState() method.
    • Controlled Components
    • Lifecycle Methods
    • Significance of keys
    • What are the differ...
  • Laravel Interviews
    • What is Laravel?
    • What are the key fe...
    • Explain the concept...
    • What is a controlle...
    • What is Blade templ...
    • How does Eloquent O...
    • Explain the concept...
    • What are middleware...
    • How do you create a...
    • What is CSRF protec...
    • What is the purpose...
    • What is the purpose...
    • Explain the concept...
    • How do you create a...
    • What is the purpose...
    • How do you define r...
    • What are named rout...
    • Explain the use of ...
    • What is the purpose...
    • What are service pr...
  • SQL Interviews
    • What is SQL?
    • What are the differ...
    • What is the differe...
    • What is a primary key?
    • What is a foreign key?
    • What are the differ...
    • What is the differe...
    • What is the use of ...
    • What is the differe...
    • What is an index in...
    • What types of index...
    • What is a subquery?
    • How do you use the ...
    • How can you find th...
    • Explain the use of ...
    • What is a view?
    • What are the limita...
    • Write a query to fe...
    • Write a query to fe...
    • Write a query to co...
    • Write a query to fe...
    • Write a query to fe...
    • Write a query to fi...
    • Write a query to fe...
    • Write a query to re...
    • Write a query to ge...
    • Write a query to ge...
    • Write a query to li...
    • Write a query to fi...
    • Write a query to fi...
    • Write a query to ge...
    • Write a query to fi...
    • Write a query to co...
    • Write a query to fi...
    • Write a query to li...
    • Write a query to fe...
    • Write a query to fi...
    • Write a query to fe...
    • Write a query to ge...
    • Write a query to co...
    • Write a query to fe...
  • JavaScript Interview Questions
    • What Exactly is Jav...
    • What are the data t...
    • What is the differe...
    • JavaScript double e...
    • What is a Closure i...
    • What is Hoisting in...
    • Understanding "this...
    • What Are JavaScript...
    • Null vs Undefined i...
    • How Does JavaScript...
    • What is a Promise i...
    • Async/Await in Java...
    • Event Delegation in...
    • JavaScript Modules ...
    • How to Prevent a Fu...
    • JavaScript Intervie...
    • JavaScript Intervie...
    • What is bind() in J...
    • Event Bubbling vs. ...
    • Deep Copy vs Shallo...
    • What is the new Key...
PHP Frameworks
  • Laravel
    • Laravel Topics
    • Laravel 7 Installation
    • Install laravel 8
    • Laravel 8 Routing
    • Laravel Controllers
    • Views and Blade lar...
    • Database and Eloque...
    • Authentication and ...
    • CSRF Protection
    • Laravel Model
    • Database: Query Bui...
Routine Use
  • Linux
    • How to Delete a Fil...
    • Install lemp in ubu...
    • How to check packag...
    • Navigating the File...
    • Managing Files and ...
    • Viewing and Editing...
    • Managing Processes ...
    • Scheduling Tasks wi...
    • Disk Usage Analysis...
    • File and Directory ...
Blogs
  • Blogs
    • Free Hosting on AWS...
    • PHP 8.6 Partial Fun...
    • What is SEO?
    • Zoho Free Mail
    • Speed Up Your Appli...
    • What is a JavaScrip...
    • Laravel vs Lumen: T...
    • MySQL vs PostgreSQL...
    • Automate Free MySQL...
    • How to Use Google A...
    • What is n8n?
    • Cloud Platform Comp...
    • Top Common Mistakes...
    • PHP 8.5: The Pipeli...
    • Google Antigravity ...
    • How to Optimize Que...
    • React vs Angular vs...
    • Base44: Features, P...
    • Difference Between ...
    • HTTP Status Codes E...
    • Build Native Mobile...
    • Top 10 JavaScript F...
    • JIRA, Waterfall, an...
    • WebSockets in Moder...
    • A Complete Real-Wor...
    • Why Developers Shou...
    • Service-Based Compa...
    • Bootstrap vs Tailwi...
    • Direct Prompt vs St...
    • Top 25 SEO HTML Tag...
    • Docker Commands Che...
    • Authentication vs A...
    • Top AI Portals in 2...
    • What is Replit? Com...
    • Laravel 13 Released...
    • NEET Paper Leak Pre...