ekurt 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,508 @@
1
+ [
2
+ {
3
+ "slug": "introduction-to-git-and-version-control",
4
+ "title": "GIT101 - Introduction to Git",
5
+ "lesson": "GIT101",
6
+ "series": "git",
7
+ "shortTitle": "Introduction to Git",
8
+ "description": "Learn what Git, version control systems, and how developers track and manage changes effectively.",
9
+ "date": "2022-07-02",
10
+ "readingMinutes": 2,
11
+ "body": "Git is one of the most essential tools for modern developers. Whether you're working alone or collaborating with a team, Git enables you to track changes, experiment safely, and collaborate effectively.\n\nIn this chapter, we explore the fundamentals of version control, understand how Git operates, and learn why it is widely used in modern software development.\n\n## What Is Version Control?\n\nVersion control is a system that records changes made to files over time. \nIt allows developers to:\n\n- Restore previous versions\n- Compare differences\n- Collaborate without overwriting each other's work\n- Experiment safely using isolated environments called branches\n\nVersion control can be described as the history and backup system of your project.\n\n---\n\n## Why Developers Use Git\n\nGit is a distributed version control system. This means every developer has a full copy of the project history stored locally on their machine.\n\nKey advantages:\n\n- Works offline\n- Fast and lightweight\n- Easy branching and merging\n- Secure experimentation\n- Simple collaboration via GitHub, GitLab, or Bitbucket\n\n---\n\n## How Git Organizes Your Project (Explanation Without Diagram)\n\nGit operates using three main areas:\n\n- **Working Directory**: The place where you edit your actual project files.\n- **Staging Area (Index)**: A preparation space where you select the changes you want to include in your next commit.\n- **Repository (.git folder)**: The internal database where Git permanently stores your project's history.\n\nThe general workflow is explained like this:\n\nYou make changes in your Working Directory. \nYou select which changes to include by moving them into the Staging Area. \nFinally, you save those staged changes into the Repository as a commit.\n\n---\n\n## Creating Your First Git Repository\n\n### Initialize Git\n\n```bash\n$ git init\nInitialized empty Git repository in /project/.git/\n```\n\nThis creates the .git folder, which contains the entire version history.\n\n---\n\n### Check Repository Status\n\n```bash\n$ git status\nOn branch main\n\nNo commits yet\nnothing to commit\n```\n\nThis command shows what is happening inside your project at any moment.\n\n---\n\n### Add Files to the Staging Area\n\n```bash\n$ git add index.html\n```\n\nOr add all files:\n\n```bash\n$ git add .\n```\n\n---\n\n### Make Your First Commit\n\n```bash\n$ git commit -m \"Initial commit\"\n```\n\nA commit represents a snapshot of your project at a specific point in time.\n\n---\n\n## Git vs GitHub\n\n| Git | GitHub |\n| --------------------------------- | ------------------------------------------------------------------------ |\n| A local version control tool | An online platform for hosting Git repositories |\n| Works offline | Requires internet |\n| Manages files and version history | Provides collaboration features such as pull requests and issue tracking |\n\n---\n\n## Visual Suggestion (Copyright Safe)\n\nYou may create your own custom diagram using simple boxes or arrows in tools such as Excalidraw, Figma, or Whimsical. \nThis prevents copyright issues and ensures you have lightweight, SEO-friendly visual assets.\n\n---\n\n## Summary\n\nIn this chapter, you learned:\n\n- What version control is\n- Why Git is essential for developers\n- How Git structures a project\n- How to initialize and commit for the first time\n- The difference between Git and GitHub\n\nNext, we will continue with installing Git and configuring your environment correctly.\n\n---\n"
12
+ },
13
+ {
14
+ "slug": "installing-git-and-setting-up-environment",
15
+ "title": "GIT102 - Installing Git & Setup Guide",
16
+ "lesson": "GIT102",
17
+ "series": "git",
18
+ "shortTitle": "Installing Git & Setup Guide",
19
+ "description": "Step-by-step guide to installing Git on Windows, macOS, and Linux, and configuring your development environment properly.",
20
+ "date": "2022-07-02",
21
+ "readingMinutes": 2,
22
+ "body": "Setting up Git correctly is the first practical step in becoming comfortable with version control. \nIn this chapter, we will walk through installing Git on Windows, macOS, and Linux, and configure your system with essential Git settings.\n\n## Why Proper Installation Matters\n\nA correct Git setup ensures that your commits are traceable and consistent across all your projects. \nIncorrect or missing configuration may lead to issues such as anonymous commits, inconsistent formatting, or authentication errors when working with remote repositories.\n\n---\n\n## Installing Git on Windows\n\nThe easiest way to install Git on Windows is through the official installer:\n\n1. Visit the official Git website: \nhttps://git-scm.com/download/win \n\n2. Download the newest installer. \n3. Run the installation wizard. \n\nRecommended installer options:\n\n- Choose \"Git from the command line and also from 3rd-party software\" \n- Select your preferred editor (VS Code is a common choice) \n- Enable Unix-style line endings \n- Use Git Credential Manager \n\nVerify installation:\n\n```bash\ngit --version\n```\n\n---\n\n## Installing Git on macOS\n\nUsing Homebrew (recommended):\n\n```bash\nbrew install git\n```\n\nWithout Homebrew, download from the official page: \nhttps://git-scm.com/download/mac\n\nVerify installation:\n\n```bash\ngit --version\n```\n\n---\n\n## Installing Git on Linux\n\n### Ubuntu / Debian\n\n```bash\nsudo apt update\nsudo apt install git\n```\n\n### Fedora\n\n```bash\nsudo dnf install git\n```\n\n### Arch Linux\n\n```bash\nsudo pacman -S git\n```\n\nVerify installation:\n\n```bash\ngit --version\n```\n\n---\n\n## First-Time Git Configuration\n\nSet your username:\n\n```bash\ngit config --global user.name \"Your Name\"\n```\n\nSet your email:\n\n```bash\ngit config --global user.email \"your.email@example.com\"\n```\n\nCheck current configuration:\n\n```bash\ngit config --list\n```\n\n---\n\n## Setting a Default Editor\n\nUse VS Code:\n\n```bash\ngit config --global core.editor \"code -w\"\n```\n\nUse Vim:\n\n```bash\ngit config --global core.editor \"vim\"\n```\n\n---\n\n## Enabling Helpful Git Features\n\nAuto-correct typos:\n\n```bash\ngit config --global help.autocorrect 1\n```\n\nColorized output:\n\n```bash\ngit config --global color.ui auto\n```\n\n---\n\n## Verifying Everything Works\n\nRun a simple command to ensure Git is responding:\n\n```bash\ngit status\n```\n\nIf you see a message like:\n\n```bash\nfatal: not a git repository (or any of the parent directories): .git\n```\n\nThis simply means you are not inside a Git repository yet. \nYou will initialize one in the next chapter.\n\n---\n\n## Summary\n\nIn this chapter, you learned:\n\n- How to install Git on Windows, macOS, and Linux \n- How to configure your username and email \n- How to set your preferred code editor \n- How to enable helpful Git convenience settings \n- How to verify that Git is installed and working properly \n\nNext, you will learn how to create your first **Git repository** and start tracking your project files.\n\n---\n"
23
+ },
24
+ {
25
+ "slug": "understanding-git-repositories-local-remote",
26
+ "title": "GIT103 - Understanding Repositories",
27
+ "lesson": "GIT103",
28
+ "series": "git",
29
+ "shortTitle": "Understanding Repositories",
30
+ "description": "Learn how Git repositories work, the difference between local and remote repos, and how Git stores your project history internally.",
31
+ "date": "2022-07-03",
32
+ "readingMinutes": 2,
33
+ "body": "Understanding how Git repositories work is essential to mastering version control. \nA repository (often called a \"repo\") is where Git stores your project files, history, and metadata. \nIn this chapter, you will learn how local and remote repositories operate and how they work together in real development workflows.\n\n## What Is a Git Repository?\n\nA Git repository is a structured storage area containing:\n\n- All your project files\n- The entire history of file changes\n- Commit metadata\n- Branches and tags\n- Configuration files used by Git\n\nA repository is created when you run:\n\n```bash\ngit init\n```\n\nThis command creates a hidden directory named `.git` inside your project. \nThis folder contains the complete database of your repository.\n\n---\n\n## Local Repositories\n\nA **local repository** exists entirely on your computer. \nIt includes three main components:\n\n- Working Directory\n- Staging Area (Index)\n- Repository (the .git folder)\n\nLocal repositories allow you to:\n\n- Commit offline\n- Create new branches\n- Restore previous versions\n- Experiment without risk\n- Manage your complete history locally\n\nNo internet connection is required to use Git locally.\n\n---\n\n## Remote Repositories\n\nA **remote repository** is a version of your project stored on a server. \nPopular hosting services include:\n\n- GitHub\n- GitLab\n- Bitbucket\n\nRemote repositories enable:\n\n- Cloud backup of your project\n- Collaboration with teams\n- Pull Requests and code reviews\n- Issue tracking\n- Continuous Integration (CI) setups\n\nYou sync changes between your **local** and **remote** repositories using Git commands like `push` and `pull`.\n\n---\n\n## Linking a Local Repository to a Remote\n\nAfter creating a repository on a platform such as GitHub, you can link it to your local project:\n\n```bash\ngit remote add origin https://github.com/username/myproject.git\n```\n\nVerify that the remote was added:\n\n```bash\ngit remote -v\n```\n\nYou will see:\n\n```bash\norigin https://github.com/username/myproject.git (fetch)\norigin https://github.com/username/myproject.git (push)\n```\n\n---\n\n## Cloning an Existing Remote Repository\n\nTo download a remote repository and set it up locally:\n\n```bash\ngit clone https://github.com/username/myproject.git\n```\n\nCloning will automatically:\n\n- Create a project folder\n- Copy all project files\n- Download the entire commit history\n- Configure the remote named \"origin\"\n- Set the default branch\n\nAfter this, you can start committing immediately.\n\n---\n\n## Inspecting Repository Structure\n\nTo see which files Git is tracking:\n\n```bash\ngit ls-files\n```\n\nTo view hidden files:\n\n```bash\nls -a\n```\n\nInside the `.git` folder, you will find:\n\n- `objects/` (stores commits, trees, versions)\n- `refs/` (branches and tags)\n- `config` (repository settings)\n- `HEAD` (points to the current branch)\n\nThese internal files should not be edited manually.\n\n---\n\n## Changing or Removing a Remote\n\nRemove a remote:\n\n```bash\ngit remote remove origin\n```\n\nUpdate a remote URL:\n\n```bash\ngit remote set-url origin https://newurl.git\n```\n\n---\n\n## Summary\n\nIn this chapter, you learned:\n\n- What a Git repository is\n- How local and remote repositories work\n- How Git organizes and stores your project history\n- How to connect a local repo to a remote server\n- How to clone existing repositories\n- How to inspect repository structure and remotes\n\nWith this foundational knowledge, you are now ready to explore essential Git commands in the next chapter.\n\n---\n"
34
+ },
35
+ {
36
+ "slug": "basic-git-commands-add-commit-status-log",
37
+ "title": "GIT104 - Essential Git Commands",
38
+ "lesson": "GIT104",
39
+ "series": "git",
40
+ "shortTitle": "Essential Git Commands",
41
+ "description": "Learn the essential Git commands used daily by developers, including add, commit, status, and log.",
42
+ "date": "2022-07-05",
43
+ "readingMinutes": 2,
44
+ "body": "Mastering basic Git commands is essential for working efficiently with version control. \nIn this chapter, you will learn how to stage files, create commits, inspect repository status, and explore commit history.\n\n## Understanding the Git Workflow\n\nGit operations typically follow this three-step workflow:\n\n1. Modify files in your Working Directory\n2. Stage the changes using git add\n3. Save the changes using git commit\n\nThese commands form the foundation of all Git usage.\n\n---\n\n## Checking the Status of Your Repository\n\nThe git status command shows what is happening inside your project:\n\n```bash\ngit status\n```\n\nExample output:\n\n```bash\nOn branch main\nChanges not staged for commit:\n modified: index.html\n```\n\n---\n\n## Staging Files with git add\n\nStage a single file:\n\n```bash\ngit add index.html\n```\n\nStage multiple files:\n\n```bash\ngit add file1.js file2.css\n```\n\nStage all modified files:\n\n```bash\ngit add .\n```\n\nUnstage a file (remove it from staging area):\n\n```bash\ngit restore --staged index.html\n```\n\n---\n\n## Creating Commits with git commit\n\nA commit is a snapshot of your project.\n\nCreate a simple commit:\n\n```bash\ngit commit -m \"Add homepage layout\"\n```\n\nCommit with a detailed message:\n\n```bash\ngit commit -m \"Fix login bug\" -m \"Resolved issue with token validation and improved error handling\"\n```\n\nAmend the previous commit:\n\n```bash\ngit commit --amend\n```\n\n---\n\n## Viewing Commit History with git log\n\nShow full commit history:\n\n```bash\ngit log\n```\n\nTypical output:\n\n```bash\ncommit a3f1c9d2b1e4\nAuthor: Your Name <your.email@example.com>\nDate: Tue Jan 12 14:22:01 2025\n\n Add header component\n```\n\nCompact view:\n\n```bash\ngit log --oneline\n```\n\nGraph view:\n\n```bash\ngit log --oneline --graph --all\n```\n\n---\n\n## Skipping the Staging Area (Optional)\n\nCommit tracked changes without staging:\n\n```bash\ngit commit -am \"Update styles\"\n```\n\nNotes:\n\n- Only works for tracked files\n- New files still require git add\n\n---\n\n## Removing Files with git rm\n\nDelete a tracked file:\n\n```bash\ngit rm oldfile.js\n```\n\nRemove file from Git but keep it locally:\n\n```bash\ngit rm --cached settings.json\n```\n\n---\n\n## Summary\n\nIn this chapter, you learned:\n\n- How to check repository status\n- How to stage and unstage files\n- How to create commits\n- How to view commit history\n- How to modify or skip the staging step\n- How to remove files using Git\n\nThese commands are used every day by developers and form the backbone of all Git workflows.\n\nNext, we will explore branching in Git and learn how to create, switch, and merge branches effectively.\n\n---\n"
45
+ },
46
+ {
47
+ "slug": "git-branching-creating-switching-merging",
48
+ "title": "GIT105 - Working with Branches",
49
+ "lesson": "GIT105",
50
+ "series": "git",
51
+ "shortTitle": "Working with Branches",
52
+ "description": "Learn how Git branches work, how to create and switch branches, and how to merge changes effectively in your projects.",
53
+ "date": "2022-07-09",
54
+ "readingMinutes": 1,
55
+ "body": "Branching is one of Git's most powerful features. \nBranches allow developers to isolate work, experiment safely, and collaborate without interrupting the main codebase.\n\n## What Is a Branch?\n\nA branch is a lightweight pointer to a specific commit. \nIt enables safe experimentation and parallel development.\n\nCommon branch examples:\n\n- main\n- develop\n- feature/homepage\n- bugfix/login\n\n---\n\n## Creating a New Branch\n\nCreate a branch named feature/homepage:\n\n```bash\ngit branch feature/homepage\n```\n\nCreate AND switch to it immediately:\n\n```bash\ngit checkout -b feature/homepage\n```\n\nEquivalent commands:\n\n```bash\ngit branch feature/homepage\ngit checkout feature/homepage\n```\n\n---\n\n## Listing Branches\n\nShow all local branches:\n\n```bash\ngit branch\n```\n\nShow local and remote branches:\n\n```bash\ngit branch -a\n```\n\nExample output:\n\n```bash\n* main\n feature/homepage\n```\n\n---\n\n## Switching Between Branches\n\nSwitch to another branch:\n\n```bash\ngit checkout feature/homepage\n```\n\nSwitch back to main:\n\n```bash\ngit checkout main\n```\n\nModern Git commands:\n\n```bash\ngit switch feature/homepage\ngit switch main\n```\n\n---\n\n## Merging Branches\n\nFirst switch to the branch you want to merge INTO:\n\n```bash\ngit checkout main\n```\n\nThen merge your feature branch:\n\n```bash\ngit merge feature/homepage\n```\n\nGit will attempt an automatic merge (fast-forward or merge commit).\n\n---\n\n## Handling Merge Conflicts\n\nIf two branches edit the same lines of code, Git will produce a conflict.\n\nA conflict looks like this:\n\n```bash\n<<<<<<< HEAD\nyour current changes\n======\nincoming changes from merged branch\n>>>>>>> feature/homepage\n```\n\nResolve conflicts by:\n\n1. Editing the file\n2. Choosing the correct content\n3. Removing conflict markers\n4. Staging the file:\n\n```bash\ngit add filename\n```\n\n5. Completing the merge:\n\n```bash\ngit commit\n```\n\n-\n"
56
+ },
57
+ {
58
+ "slug": "working-with-remote-repositories",
59
+ "title": "GIT106 - Remote Repositories Explained",
60
+ "lesson": "GIT106",
61
+ "series": "git",
62
+ "shortTitle": "Remote Repositories Explained",
63
+ "description": "Learn how to connect your local Git project to remote repositories using GitHub, GitLab, and Bitbucket. Understand push, pull, fetch, and remote management commands.",
64
+ "date": "2022-07-13",
65
+ "readingMinutes": 2,
66
+ "body": "Remote repositories allow you to store your project on external servers and collaborate with others. \nPlatforms like GitHub, GitLab, and Bitbucket make it easy to back up your projects and share work with teams.\n\n## What Is a Remote Repository?\n\nA remote repository is a version of your project hosted on a server. \nIt enables collaboration, backups, automation, and more. \n\nCommon remote platforms:\n\n- GitHub \n- GitLab \n- Bitbucket \n\nRemote repositories do not replace your local repo. \nInstead, your local and remote repositories synchronize via Git commands like push, pull, and fetch.\n\n---\n\n## Adding a Remote Repository\n\nAfter creating a new repository on a platform like GitHub, link it to your local project:\n\n```bash\ngit remote add origin https://github.com/username/myproject.git\n```\n\nVerify the remote:\n\n```bash\ngit remote -v\n```\n\nExpected output:\n\n```bash\norigin https://github.com/username/myproject.git (fetch)\norigin https://github.com/username/myproject.git (push)\n```\n\n---\n\n## Pushing Changes to a Remote Repository\n\nYour first push must specify the upstream branch:\n\n```bash\ngit push -u origin main\n```\n\nFuture pushes require only:\n\n```bash\ngit push\n```\n\nThis uploads your local commits to the remote server.\n\n---\n\n## Pulling Changes From Remote\n\nTo download and merge changes from the remote to your local repository:\n\n```bash\ngit pull\n```\n\nThis performs two actions:\n\n1. Fetch remote changes \n2. Merge them into your current branch \n\n---\n\n## Fetching Without Merging\n\nFetch downloads remote changes without modifying your working files:\n\n```bash\ngit fetch\n```\n\nUse this when you want to inspect updates before merging.\n\nCompare fetched updates with your branch:\n\n```bash\ngit diff main origin/main\n```\n\n---\n\n## Changing or Removing a Remote\n\nUpdate the remote URL:\n\n```bash\ngit remote set-url origin https://gitlab.com/newrepo.git\n```\n\nRemove a remote entirely:\n\n```bash\ngit remote remove origin\n```\n\n---\n\n## Cloning a Remote Repository\n\nClone copies the entire project history and sets up the origin remote automatically:\n\n```bash\ngit clone https://github.com/username/project.git\n```\n\nThis creates:\n\n- A new folder \n- A complete history copy \n- A configured remote named \"origin\" \n\n---\n\n## Working With Multiple Remotes\n\nYou may add additional remotes for collaboration:\n\n```bash\ngit remote add upstream https://github.com/original-author/project.git\n```\n\nFetch updates from this remote:\n\n```bash\ngit fetch upstream\n```\n\nMerge changes into your local branch:\n\n```bash\ngit merge upstream/main\n```\n\n---\n\n## Checking Remote Information\n\nList all remotes:\n\n```bash\ngit remote\n```\n\nShow detailed info:\n\n```bash\ngit remote show origin\n```\n\n---\n\n## Summary\n\nIn this chapter, you learned:\n\n- What remote repositories are \n- How to add, verify, and remove remotes \n- How to push and pull changes \n- How to fetch updates without merging \n- How to clone remote repositories \n- How to work with multiple remotes \n\nWith a solid understanding of remote repositories, you are ready to handle more advanced Git collaboration and synchronization workflows.\n\nNext, we’ll dive deeper into **merge conflicts** and how to resolve them effectively.\n\n---\n"
67
+ },
68
+ {
69
+ "slug": "git-merge-conflicts-and-resolution",
70
+ "title": "GIT107 - Handling Merge Conflicts",
71
+ "lesson": "GIT107",
72
+ "series": "git",
73
+ "shortTitle": "Handling Merge Conflicts",
74
+ "description": "Learn what merge conflicts are, why they happen, and how to resolve them safely using Git's conflict markers and merge tools.",
75
+ "date": "2022-07-17",
76
+ "readingMinutes": 2,
77
+ "body": "Merge conflicts are a normal part of working with Git, especially when collaborating on shared code. \nA merge conflict occurs when Git cannot automatically combine changes between branches because the same part of a file was modified in two different ways.\n\nUnderstanding how conflicts happen and how to fix them is an essential Git skill.\n\n## Why Merge Conflicts Happen\n\nMerge conflicts usually occur when:\n\n- Two branches modify the same line of code\n- One branch deletes a file that another branch edits\n- Two developers edit the same file simultaneously\n- Automatic merge is not possible due to overlapping changes\n\nGit stops the merge and asks for human intervention.\n\n---\n\n## Creating a Merge Conflict (Example)\n\nImagine two branches: main and feature/update-title\n\nOn main, the file says:\n\n```bash\ntitle = \"Homepage\"\n```\n\nOn feature/update-title, the file says:\n\n```bash\ntitle = \"New Homepage Title\"\n```\n\nWhen merging feature/update-title into main:\n\n```bash\ngit checkout main\ngit merge feature/update-title\n```\n\nGit will detect conflicting edits on the same line and stop the merge.\n\n---\n\n## What a Merge Conflict Looks Like\n\nGit adds special markers to show the conflicting sections inside the file:\n\n```bash\n<<<<<<< HEAD\ntitle = \"Homepage\"\n======\ntitle = \"New Homepage Title\"\n>>>>>>> feature/update-title\n```\n\nMeaning of markers:\n\n- HEAD block = your current branch\n- After ====== = incoming changes\n- After >>>>>>> = which branch the change came from\n\n---\n\n## How to Resolve a Merge Conflict\n\nSteps to fix the conflict:\n\n1. Open the conflicted file\n2. Decide which version to keep\n3. Remove all conflict markers\n4. Save the resolved file\n5. Stage the file:\n\n```bash\ngit add filename\n```\n\n6. Complete the merge:\n\n```bash\ngit commit\n```\n\nGit now records a merge commit that includes your resolved changes.\n\n---\n\n## Resolution Options\n\nDepending on the situation, you may choose to:\n\n- Keep your version\n- Keep the incoming version\n- Combine both changes\n- Rewrite the section completely\n\nExample combining both:\n\n```bash\ntitle = \"Homepage - New Title\"\n```\n\n---\n\n## Using Git Merge Tools\n\nGit supports external merge tools for easier conflict resolution.\n\nSet a mergetool globally:\n\n```bash\ngit config --global merge.tool vimdiff\n```\n\nRun the merge tool:\n\n```bash\ngit mergetool\n```\n\nCommon tools:\n\n- vimdiff\n- kdiff3\n- meld\n- Beyond Compare\n\n---\n\n## Viewing Conflict Status\n\nList files with conflicts:\n\n```bash\ngit status\n```\n\nGit displays:\n\n```bash\nboth modified: filename\n```\n\n---\n\n## Aborting a Merge\n\nIf you want to cancel the merge and restore the previous state:\n\n```bash\ngit merge --abort\n```\n\nUseful when the conflict is too complicated or the merge attempt was a mistake.\n\n---\n\n## Summary\n\nIn this chapter, you learned:\n\n- What merge conflicts are and why they happen\n- How Git marks conflicted sections\n- How to manually resolve conflicts\n- How to stage and commit resolved files\n- How to use Git mergetool\n- How to abort a merge if necessary\n\nMerge conflicts are completely normal and nothing to fear. \nWith practice, they become easy to understand and resolve efficiently.\n\nNext, we will explore Git workflow models such as feature branching, Git Flow, and trunk-based development.\n\n---\n"
78
+ },
79
+ {
80
+ "slug": "git-workflow-models",
81
+ "title": "GIT108 - Git Workflow Models",
82
+ "lesson": "GIT108",
83
+ "series": "git",
84
+ "shortTitle": "Git Workflow Models",
85
+ "description": "Learn the most popular Git workflow strategies used by modern development teams to organize collaboration and code delivery.",
86
+ "date": "2022-07-21",
87
+ "readingMinutes": 2,
88
+ "body": "Different teams use different Git workflows depending on project size, release cycles, and collaboration needs. \nIn this chapter, we explore three widely used Git workflow models: Feature Branch Workflow, Git Flow, and Trunk-Based Development. \n\nUnderstanding these models will help you choose the right strategy for your own projects.\n\n## 1. Feature Branch Workflow\n\nFeature Branch Workflow is one of the simplest and most popular Git strategies. \nEach new feature or fix is developed inside its own branch, separate from main.\n\n### How it works\n\n1. Create a new branch for each feature:\n\n```bash\ngit checkout -b feature/new-ui\n```\n\n2. Work and commit changes on the feature branch \n3. Merge the branch into main when done:\n\n```bash\ngit checkout main\ngit merge feature/new-ui\n```\n\n### Benefits\n\n- Keeps main clean and stable \n- Easy to review changes via pull requests \n- Ideal for small to medium teams \n\n### Common branch names\n\n- feature/login \n- feature/user-profile \n- feature/checkout \n\n---\n\n## 2. Git Flow Workflow\n\nGit Flow is a more structured workflow used by larger teams or projects with scheduled releases. \nIt introduces multiple long-living branches with specific responsibilities.\n\n### Main branches\n\n- **main** = production code \n- **develop** = integration branch \n\n### Supporting branches\n\n- feature/* \n- release/* \n- hotfix/* \n\n### Example: creating a feature branch\n\n```bash\ngit checkout develop\ngit checkout -b feature/payment-integration\n```\n\n### Example: starting a release branch\n\n```bash\ngit checkout develop\ngit checkout -b release/1.2.0\n```\n\n### Pros\n\n- Ideal for complex products \n- Clear separation of work stages \n- Supports planned release cycles \n\n### Cons\n\n- Too heavy for small teams \n- Lots of branching and merging \n- Harder to maintain for fast-moving products \n\n---\n\n## 3. Trunk-Based Development\n\nTrunk-Based Development is a fast and modern workflow where developers work directly on main or short-lived branches.\n\n### Key characteristics\n\n- Developers commit small changes frequently \n- Branches live for only hours or a few days \n- Continuous Integration (CI) tests every commit \n- Encourages rapid delivery and early feedback \n\n### Example: creating a short-lived branch\n\n```bash\ngit checkout -b fix/typo\n```\n\nCommit quickly and merge back into main:\n\n```bash\ngit checkout main\ngit merge fix/typo\n```\n\n### Best used when\n\n- Team releases often \n- Code must stay deployable at all times \n- Strong CI practices exist \n\n---\n\n## Comparison Table\n\nFeature Branch = Simple and great for small teams \nGit Flow = Structured and ideal for large projects \nTrunk-Based = Fast and CI-driven development\n\n---\n\n## Choosing the Right Workflow\n\nChoose **Feature Branch Workflow** if your team wants a clean, easy-to-understand approach.\n\nChoose **Git Flow** if you have formal release cycles or a large team working on complex product phases.\n\nChoose **Trunk-Based Development** if you deploy often and use strong CI practices.\n\nThere is no “one-size-fits-all” approach — choose what fits your project and team culture.\n\n---\n\n## Summary\n\nIn this chapter, you learned:\n\n- The three major Git workflow models \n- How Feature Branching works \n- How Git Flow organizes large teams \n- How Trunk-Based Development supports rapid delivery \n- When to use each workflow \n\nNext, we’ll explore **rewriting Git history** using amend, rebase, and stash — powerful tools for keeping your commit history clean.\n\n---\n"
89
+ },
90
+ {
91
+ "slug": "git-rewriting-history-amend-rebase-stash",
92
+ "title": "GIT109 - Rewriting Git History",
93
+ "lesson": "GIT109",
94
+ "series": "git",
95
+ "shortTitle": "Rewriting Git History",
96
+ "description": "Learn how to rewrite Git history using amend, rebase, and stash to keep your commit history clean and organized.",
97
+ "date": "2022-07-25",
98
+ "readingMinutes": 2,
99
+ "body": "Sometimes you need to modify commit history to keep your project clean and organized. \nGit provides powerful tools for editing, reordering, and temporarily saving changes. \nIn this chapter, we cover three important techniques: **amend**, **rebase**, and **stash**.\n\n## 1. Using git commit --amend\n\nThe amend command lets you modify the most recent commit. \nYou can use it to fix commit messages or include forgotten changes.\n\n### Fixing a commit message\n\n```bash\ngit commit --amend -m \"New and improved commit message\"\n```\n\n### Adding missing changes to the last commit\n\nStage your changes:\n\n```bash\ngit add filename.js\n```\n\nThen amend:\n\n```bash\ngit commit --amend\n```\n\nThis replaces the previous commit with a new one.\n\n**Important**: Never amend commits that were already pushed to a shared remote repository. \nIt rewrites history and can cause problems for teammates.\n\n---\n\n## 2. Using git rebase (Interactive Rebase)\n\nRebase allows you to clean up your commit history by editing, deleting, or reordering commits. \nInteractive rebase is especially powerful for maintaining a clean project history.\n\n### Start an interactive rebase for the last 3 commits\n\n```bash\ngit rebase -i HEAD~3\n```\n\nGit will open an editor showing something like:\n\n```bash\npick 1a2b3c4 Add login form\npick 5d6e7f8 Fix login CSS\npick 9f0a1b2 Update API endpoint\n```\n\nYou can replace \"pick\" with commands like:\n\n- **pick** = keep the commit \n- **reword** = change commit message \n- **edit** = modify commit content \n- **squash** = combine commits \n- **drop** = delete commit \n\n### Example: squashing commits\n\nChange:\n\n```bash\npick 1a2b3c4 Add login form\npick 5d6e7f8 Fix login CSS\n```\n\nTo:\n\n```bash\npick 1a2b3c4 Add login form\nsquash 5d6e7f8 Fix login CSS\n```\n\nRebase produces a single clean commit.\n\n### Completing the rebase\n\nIf Git pauses during rebase, continue with:\n\n```bash\ngit rebase --continue\n```\n\nAbort the rebase and return to original state:\n\n```bash\ngit rebase --abort\n```\n\n---\n\n## 3. Using git stash\n\nSometimes you need to switch branches but you're not ready to commit your work. \nStash lets you save changes temporarily without committing them.\n\n### Stash your current work\n\n```bash\ngit stash\n```\n\nOr include untracked files:\n\n```bash\ngit stash -u\n```\n\n### View stash list\n\n```bash\ngit stash list\n```\n\nExample output:\n\n```bash\nstash@{0}: WIP on feature/cart\nstash@{1}: WIP on main\n```\n\n### Apply the latest stash\n\n```bash\ngit stash apply\n```\n\n### Apply and remove stash\n\n```bash\ngit stash pop\n```\n\n### Remove stashes manually\n\n```bash\ngit stash drop stash@{0}\n```\n\nRemove all stashes:\n\n```bash\ngit stash clear\n```\n\n---\n\n## When To Use Each Tool\n\n### Amend\n- Fix small mistakes \n- Add missing files \n- Update commit messages \n- Only safe before pushing \n\n### Rebase\n- Clean up messy history \n- Combine or reorder commits \n- Rewrite commit messages \n- Not recommended for shared public history \n\n### Stash\n- Save temporary work \n- Switch branches safely \n- Recover WIP later \n\n---\n\n## Summary\n\nIn this chapter, you learned:\n\n- How to modify your latest commit using `amend` \n- How to rewrite and organize commit history using `rebase` \n- How to save temporary work using `stash` \n- When to use each history-rewriting tool \n\nThese tools help keep your repository history clean, readable, and professional. \nNext, we explore helpful Git aliases and best practices to improve your daily workflow.\n\n---\n"
100
+ },
101
+ {
102
+ "slug": "git-tips-aliases-best-practices",
103
+ "title": "GIT110 - Git Tips & Best Practices",
104
+ "lesson": "GIT110",
105
+ "series": "git",
106
+ "shortTitle": "Git Tips & Best Practices",
107
+ "description": "Improve your Git workflow with helpful tips, useful aliases, and professional best practices for clean and efficient version control.",
108
+ "date": "2022-07-30",
109
+ "readingMinutes": 2,
110
+ "body": "By now, you know how Git works and how to use its essential commands. \nIn this final chapter, we explore practical tips, useful shortcuts, and professional best practices that help you write cleaner commits and work more efficiently.\n\n## 1. Use Descriptive Commit Messages\n\nA good commit message explains *why* changes were made, not just *what* was changed.\n\nExamples of bad messages:\n\n- \"fix\" \n- \"update\" \n\nExamples of good messages:\n\n- \"Fix null pointer error in login controller\" \n- \"Improve checkout performance by caching API response\" \n\nFollow the conventional format:\n\n```bash\ntype: subject\n\noptional body with more detail\n```\n\nCommon types:\n\n- feat = new feature \n- fix = bug fix \n- refactor = code restructuring \n- docs = documentation \n- style = formatting changes only \n\n---\n\n## 2. Use Git Aliases to Save Time\n\nAliases help shorten long Git commands. \nSet them globally:\n\n```bash\ngit config --global alias.co checkout\ngit config --global alias.br branch\ngit config --global alias.cm \"commit -m\"\ngit config --global alias.st status\ngit config --global alias.lg \"log --oneline --graph --all\"\n```\n\nUse them like this:\n\n```bash\ngit co main\ngit br\ngit cm \"Add product card component\"\ngit lg\n```\n\n---\n\n## 3. Keep Branches Short-Lived\n\nShort-lived branches help reduce merge conflicts. \n\nGuidelines:\n\n- Keep branches focused on a single task \n- Merge early and often \n- Avoid letting branches diverge too long \n\n---\n\n## 4. Pull Before You Push\n\nAlways make sure you have the latest changes before pushing:\n\n```bash\ngit pull\ngit push\n```\n\nThis prevents unnecessary merge conflicts.\n\n---\n\n## 5. Use .gitignore to Avoid Unwanted Files\n\nAdd a `.gitignore` file to your project root:\n\n```bash\nnode_modules/\ndist/\n.env\n.DS_Store\n```\n\nThis keeps your repository clean and avoids committing temporary or sensitive files.\n\n---\n\n## 6. Avoid Committing Large Files\n\nLarge files slow down repository history. \nUse Git LFS (Large File Storage) when necessary:\n\n```bash\ngit lfs install\ngit lfs track \"*.psd\"\n```\n\n---\n\n## 7. Write Clean Commit History\n\nGood commit history makes debugging and onboarding much easier. \n\nTips:\n\n- Use interactive rebase to clean messy commits \n- Squash unnecessary commits \n- Avoid mixing unrelated changes in a single commit \n\n---\n\n## 8. Review Changes Before Committing\n\nAlways review your staged changes:\n\n```bash\ngit diff --staged\n```\n\nThis prevents accidentally committing debug code or unnecessary files.\n\n---\n\n## 9. Use Tags for Releases\n\nTagging makes it easy to mark stable release versions:\n\n```bash\ngit tag -a v1.0.0 -m \"Initial release\"\ngit push origin v1.0.0\n```\n\n---\n\n## 10. Use Branch Protection Rules\n\nOn platforms like GitHub or GitLab, enable rules such as:\n\n- Require pull request reviews \n- Disallow force pushes \n- Require tests to pass \n\nThis helps maintain a stable main branch.\n\n---\n\n## Summary\n\nIn this chapter, you learned:\n\n- How to write clear commit messages \n- How to create helpful Git aliases \n- Best practices for branching and merging \n- How to avoid common Git mistakes \n- How to maintain a clean and professional commit history \n\nCongratulations — you’ve completed the **Git for Beginners** series. \nThese skills form the basis of strong version control practices and prepare you for the next series: **Advanced Git Techniques**.\n\n---\n"
111
+ },
112
+ {
113
+ "slug": "introduction-to-javascript",
114
+ "title": "JS101 - Introduction to JavaScript",
115
+ "lesson": "JS101",
116
+ "series": "javascript",
117
+ "shortTitle": "Introduction to JavaScript",
118
+ "description": "Learn what JavaScript is, how it works in the browser, and why it is one of the most important languages for web development.",
119
+ "date": "2023-01-07",
120
+ "readingMinutes": 2,
121
+ "body": "JavaScript is one of the core technologies of the modern web. \nTogether with HTML and CSS, it allows developers to build interactive and dynamic websites. \nIn this lesson, you will learn what JavaScript is, where it runs, and how it works behind the scenes.\n\n## What Is JavaScript?\n\nJavaScript (JS) is a high-level, interpreted programming language used primarily for web development. \nIt enables dynamic behavior in browsers such as:\n\n- Animations \n- Interactive forms \n- Real-time updates \n- DOM manipulation \n- API communication \n\nJavaScript is executed by a **JavaScript engine** inside your browser. \nExamples of engines:\n\n- V8 (Chrome, Node.js) \n- SpiderMonkey (Firefox) \n- JavaScriptCore (Safari)\n\n---\n\n## How JavaScript Works in the Browser\n\nEvery browser contains a JS engine that reads and executes JavaScript code. \nThe browser environment provides additional APIs such as:\n\n- DOM (Document Object Model) \n- BOM (Browser Object Model) \n- Fetch API \n- Events \n\nJavaScript alone cannot access files or the OS directly — it needs the browser or Node.js environment.\n\n---\n\n## Adding JavaScript to a Web Page\n\nThe simplest way to run JavaScript is by using the `<script>` tag in an HTML file.\n\nExample:\n\n```html\n<!DOCTYPE html>\n<html>\n <body>\n <h1>Hello JavaScript!</h1>\n <script>\n console.log(\"Hello from JS\");\n </script>\n </body>\n</html>\n```\n\nThe browser executes the JavaScript inside the script tag when the page loads.\n\n---\n\n## Running JavaScript in the Console\n\nBrowsers include a Developer Console where you can run JS code directly.\n\nOpen DevTools:\n\n- Chrome: Ctrl + Shift + J \n- Firefox: Ctrl + Shift + K \n- Safari: Enable Developer Menu \n\nExample commands:\n\n```js\nconsole.log(\"Hello World\");\n2 + 2\n\"JavaScript\".toUpperCase()\n```\n\nThis is a great way to test small pieces of code quickly.\n\n---\n\n## Why JavaScript Is Everywhere\n\nJavaScript has become one of the most widely used languages due to:\n\n- Works in every browser \n- Large ecosystem (React, Vue, Angular) \n- Server-side support via Node.js \n- Massive community and learning resources \n- Used for web, mobile, backend, desktop apps \n\nIt is now possible to build full applications using only JavaScript.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What JavaScript is \n- How it runs in browsers \n- What JS engines do \n- How to run JS in HTML or the browser console \n- Why JavaScript is so important \n\nIn the next lesson, we will set up your development environment and start writing real code.\n\n---\n"
122
+ },
123
+ {
124
+ "slug": "javascript-environment-setup",
125
+ "title": "JS102 - JavaScript Environment Setup",
126
+ "lesson": "JS102",
127
+ "series": "javascript",
128
+ "shortTitle": "JavaScript Environment Setup",
129
+ "description": "Learn how to set up your JavaScript development environment using VS Code, Node.js, and browser DevTools.",
130
+ "date": "2023-01-12",
131
+ "readingMinutes": 2,
132
+ "body": "Before writing JavaScript code, you need a proper development environment. \nIn this lesson, you will learn how to install the necessary tools and configure your system for modern JavaScript development.\n\n## Why You Need a Development Environment\n\nJavaScript can run directly in the browser, but using the right tools makes coding easier. \nA good environment includes:\n\n- A code editor \n- A JavaScript runtime (Node.js) \n- Browser developer tools \n- Helpful extensions and linters \n\n---\n\n## Installing VS Code\n\nVS Code is one of the most popular editors for JavaScript. \nIt offers syntax highlighting, debugging, extensions, and built-in terminal support.\n\nDownload from the official website: \nhttps://code.visualstudio.com\n\nRecommended extensions:\n\n- ES7 React/JS Snippets \n- Prettier \n- ESLint \n- Live Server \n\n---\n\n## Installing Node.js\n\nNode.js allows you to run JavaScript **outside** the browser. \nIt also includes npm (Node Package Manager), which is essential for installing libraries.\n\nDownload Node.js from: \nhttps://nodejs.org\n\nVerify the installation:\n\n```bash\nnode -v\nnpm -v\n```\n\n---\n\n## Using the Browser Console\n\nAll modern browsers include built-in developer tools. \nThe console tab allows you to run JavaScript instantly.\n\nOpen DevTools:\n\n- Chrome: Ctrl + Shift + J \n- Firefox: Ctrl + Shift + K \n- Edge: Ctrl + Shift + I \n\nExample commands:\n\n```js\nconsole.log(\"Testing JS\");\n5 * 7\n\"hello\".toUpperCase()\n```\n\n---\n\n## Creating Your First JavaScript File\n\nCreate a file named `script.js`:\n\n```js\nconsole.log(\"Hello JavaScript environment!\");\n```\n\nLink it in an HTML file:\n\n```html\n<html>\n <body>\n <script src=\"script.js\"></script>\n </body>\n</html>\n```\n\nOpen the HTML file in your browser and see the output in the console.\n\n---\n\n## Using the Terminal\n\nYou can also run JavaScript using Node.js in the terminal:\n\n```bash\nnode script.js\n```\n\nThis is useful for learning core JavaScript without needing a webpage.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- How to install VS Code \n- How to install Node.js and npm \n- How to run JavaScript in the browser and terminal \n- How to create your first JS file \n\nIn the next lesson, we will explore JavaScript variables and data types.\n\n---\n"
133
+ },
134
+ {
135
+ "slug": "javascript-variables-data-types",
136
+ "title": "JS103 - Variables & Data Types",
137
+ "lesson": "JS103",
138
+ "series": "javascript",
139
+ "shortTitle": "Variables & Data Types",
140
+ "description": "Learn how variables work in JavaScript and understand primitive data types such as string, number, boolean, null, and undefined.",
141
+ "date": "2023-01-18",
142
+ "readingMinutes": 1,
143
+ "body": "Variables allow you to store and manage data in JavaScript. \nUnderstanding variables and data types is essential before writing any meaningful application.\n\n## Declaring Variables\n\nJavaScript provides three ways to declare variables:\n\n```js\nvar name = \"Emre\";\nlet age = 30;\nconst country = \"Turkey\";\n```\n\n### var \n- Old JavaScript syntax \n- Function-scoped \n- Avoid in modern code \n\n### let \n- Block-scoped \n- Use when value will change \n\n### const \n- Block-scoped \n- Value cannot be reassigned \n\n---\n\n## Primitive Data Types\n\nJavaScript has seven primitive types. \nPrimitive means the value is not an object and has no methods attached by default.\n\n### 1. String\n\n```js\nlet city = \"Antalya\";\n```\n\nUsed for text data.\n\n### 2. Number\n\n```js\nlet score = 95;\nlet price = 12.99;\n```\n\nJS uses a single numeric type for integers and decimals.\n\n### 3. Boolean\n\n```js\nlet isLoggedIn = true;\nlet isAdmin = false;\n```\n\nRepresents true or false values.\n\n### 4. Null\n\nRepresents \"intentional absence\" of a value.\n\n```js\nlet car = null;\n```\n\n### 5. Undefined\n\nMeans a variable was declared but no value assigned.\n\n```js\nlet address;\nconsole.log(address); // undefined\n```\n\n### 6. Symbol \nUsed for unique identifiers (advanced topic).\n\n### 7. BigInt\n\n```js\nlet big = 12345678901234567890n;\n```\n\nFor very large numbers beyond Number limits.\n\n---\n\n## Checking Data Types with typeof\n\nThe typeof operator returns the type of a value.\n\n```js\nconsole.log(typeof \"Hello\"); // string\nconsole.log(typeof 42); // number\nconsole.log(typeof true); // boolean\nconsole.log(typeof undefined); // undefined\nconsole.log(typeof null); // object (JavaScript bug)\n```\n\nNote: typeof null returning \"object\" is a long-known JS quirk.\n\n---\n\n## Dynamic Typing\n\nJavaScript is **dynamically typed**. \nThis means a variable’s type can change at runtime.\n\n```js\nlet value = 100;\nvalue = \"now a string\";\n```\n\nUseful but dangerous if not used carefully.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- How to declare variables using var, let, const \n- What primitive data types exist \n- How typeof works \n- Why JavaScript is dynamically typed \n\nIn the next lesson, we will explore operators and expressions.\n\n---\n"
144
+ },
145
+ {
146
+ "slug": "javascript-operators-expressions",
147
+ "title": "JS104 - Operators & Expressions",
148
+ "lesson": "JS104",
149
+ "series": "javascript",
150
+ "shortTitle": "Operators & Expressions",
151
+ "description": "Learn how operators work in JavaScript including arithmetic, comparison, logical operators, and how expressions are evaluated.",
152
+ "date": "2023-01-25",
153
+ "readingMinutes": 1,
154
+ "body": "Operators allow you to perform calculations, compare values, and build logic in your JavaScript programs. \nAn expression is any piece of code that produces a value.\n\n## Arithmetic Operators\n\nArithmetic operators are used for basic mathematical operations.\n\n```js\nlet a = 10;\nlet b = 3;\n\na + b; // 13\na - b; // 7\na * b; // 30\na / b; // 3.333...\na % b; // 1 (remainder)\na ** b; // 1000 (exponent)\n```\n\n---\n\n## Assignment Operators\n\n```js\nlet x = 5;\nx += 3; // 8\nx -= 2; // 6\nx *= 2; // 12\n```\n\nShorter syntax makes code easier to maintain.\n\n---\n\n## Comparison Operators\n\nUsed to compare two values.\n\n```js\n5 > 3; // true\n5 < 3; // false\n5 >= 5; // true\n5 <= 4; // false\n```\n\n### Equality\n\n```js\n5 == \"5\" // true (loose equality)\n5 === \"5\" // false (strict equality)\n```\n\nAlways prefer strict equality (===).\n\n### Inequality\n\n```js\n10 !== 10 // false\n10 !== 5 // true\n```\n\n---\n\n## Logical Operators\n\nUsed for combining conditions.\n\n```js\ntrue && true // true\ntrue && false // false\ntrue || false // true\nfalse || false // false\n!true // false\n```\n\nLogical operators are essential for conditional logic.\n\n---\n\n## String Operators\n\n```js\nlet first = \"Hello\";\nlet second = \"World\";\n\nfirst + \" \" + second; // \"Hello World\"\n```\n\n---\n\n## Expressions in JavaScript\n\nAn expression produces a value.\n\nExamples:\n\n```js\n2 + 2\n\"JS\" + \"101\"\nisLoggedIn && hasToken\n```\n\nAll of these generate a result and can be assigned to variables.\n\n---\n\n## Operator Precedence\n\nSome operators run before others. \nMultiplication happens before addition.\n\n```js\n2 + 3 * 4 // 14 (not 20)\n```\n\nUse parentheses to control execution order:\n\n```js\n(2 + 3) * 4 // 20\n```\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- Arithmetic operators \n- Assignment operators \n- Comparison and equality operators \n- Logical operators \n- String concatenation \n- How expressions produce values \n- Operator precedence \n\nNext, we will introduce **control flow** and learn how JavaScript makes decisions using if, else, switch and the ternary operator.\n\n---\n"
155
+ },
156
+ {
157
+ "slug": "javascript-control-flow-basics",
158
+ "title": "JS105 - Control Flow Basics",
159
+ "lesson": "JS105",
160
+ "series": "javascript",
161
+ "shortTitle": "Control Flow Basics",
162
+ "description": "Learn how JavaScript makes decisions using if, else, switch, and the ternary operator to control how your program runs.",
163
+ "date": "2023-02-01",
164
+ "readingMinutes": 2,
165
+ "body": "Control flow allows your programs to make decisions and respond to different conditions. \nWithout control flow, every script would run the same way every time. \nIn this lesson, we introduce if statements, else blocks, switch cases, and the ternary operator.\n\n## if Statement\n\nThe if statement runs a block of code only when a condition is true.\n\n```js\nlet age = 20;\n\nif (age >= 18) {\n console.log(\"You are an adult\");\n}\n```\n\n---\n\n## if ... else\n\nUse else to run a different block when the condition is false.\n\n```js\nlet score = 55;\n\nif (score >= 60) {\n console.log(\"Passed\");\n} else {\n console.log(\"Failed\");\n}\n```\n\n---\n\n## else if Chain\n\nUse else if for multiple conditions.\n\n```js\nlet temperature = 28;\n\nif (temperature > 30) {\n console.log(\"Too hot\");\n} else if (temperature >= 20) {\n console.log(\"Perfect weather\");\n} else {\n console.log(\"Too cold\");\n}\n```\n\n---\n\n## switch Statement\n\nSwitch is useful when you need to compare a value against many possible matches.\n\n```js\nlet day = \"Monday\";\n\nswitch (day) {\n case \"Monday\":\n console.log(\"Start of the week\");\n break;\n case \"Friday\":\n console.log(\"Almost weekend\");\n break;\n default:\n console.log(\"Midweek day\");\n}\n```\n\n---\n\n## Ternary Operator\n\nA shorter form of an if ... else expression.\n\n```js\nlet isLoggedIn = true;\n\nlet message = isLoggedIn \n ? \"Welcome back!\"\n : \"Please log in\";\n\nconsole.log(message);\n```\n\nThis is commonly used in UI logic.\n\n---\n\n## Truthy and Falsy Values\n\nJavaScript treats some values as \"true\" or \"false\" in boolean contexts.\n\nFalsy values:\n\n- false \n- 0 \n- \"\" \n- null \n- undefined \n- NaN \n\nEverything else is truthy.\n\n```js\nif (\"\") {\n console.log(\"This won't run\");\n}\n\nif (\"Hello\") {\n console.log(\"This will run\");\n}\n```\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- How if, else, and else if work \n- How switch statements simplify multiple comparisons \n- How to write compact logic with the ternary operator \n- How truthy and falsy values behave in JavaScript \n\nIn the next lesson, we will explore **functions** — one of the most important building blocks in JavaScript.\n\n---\n"
166
+ },
167
+ {
168
+ "slug": "javascript-functions-explained",
169
+ "title": "JS106 - Functions Explained",
170
+ "lesson": "JS106",
171
+ "series": "javascript",
172
+ "shortTitle": "Functions Explained",
173
+ "description": "Learn how functions work in JavaScript including declarations, expressions, parameters, return values, and arrow functions.",
174
+ "date": "2023-02-07",
175
+ "readingMinutes": 2,
176
+ "body": "Functions are one of the most important concepts in JavaScript. \nThey allow you to group reusable blocks of code and give structure to your programs.\n\n## Function Declaration\n\nA function declaration defines a function with a name.\n\n```js\nfunction greet() {\n console.log(\"Hello\");\n}\n\ngreet(); // runs the function\n```\n\n---\n\n## Function With Parameters\n\nParameters allow you to pass values into a function.\n\n```js\nfunction sayHello(name) {\n console.log(\"Hello, \" + name);\n}\n\nsayHello(\"Emre\");\n```\n\nA parameter is the variable name inside the function. \nAn argument is the actual value passed when calling the function.\n\n---\n\n## Returning Values\n\nFunctions can return values using the return keyword.\n\n```js\nfunction add(a, b) {\n return a + b;\n}\n\nlet result = add(3, 4); // 7\n```\n\nOnce return is executed, the function stops running.\n\n---\n\n## Function Expression\n\nFunctions can also be stored in variables.\n\n```js\nconst multiply = function(x, y) {\n return x * y;\n};\n\nconsole.log(multiply(2, 5)); // 10\n```\n\nFunction expressions are useful when passing functions as arguments.\n\n---\n\n## Arrow Functions (ES6+)\n\nArrow functions offer a shorter syntax.\n\n```js\nconst greet = () => {\n console.log(\"Hi!\");\n};\n```\n\nWith parameters:\n\n```js\nconst square = (n) => n * n;\n```\n\nArrow functions automatically return the expression when written without braces.\n\n---\n\n## Default Parameters\n\nYou can assign default values to parameters.\n\n```js\nfunction welcome(name = \"Guest\") {\n console.log(\"Welcome, \" + name);\n}\n\nwelcome(); // Welcome, Guest\nwelcome(\"Emre\");\n```\n\n---\n\n## Rest Parameters\n\nRest parameters gather multiple arguments into an array.\n\n```js\nfunction sum(...numbers) {\n return numbers.reduce((a, b) => a + b, 0);\n}\n\nconsole.log(sum(1, 2, 3, 4)); // 10\n```\n\n---\n\n## Higher-Order Functions\n\nA higher-order function is one that takes another function as an argument.\n\n```js\nfunction applyTwice(fn) {\n fn();\n fn();\n}\n\napplyTwice(() => console.log(\"Run\"));\n```\n\nThis is the basis for powerful JS patterns.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- Function declarations and expressions \n- Parameters and arguments \n- return keyword \n- Arrow functions \n- Default and rest parameters \n- Higher-order functions \n\nIn the next lesson, we will explore **arrays and objects** — the core data structures of JavaScript.\n\n---\n"
177
+ },
178
+ {
179
+ "slug": "javascript-arrays-objects-basics",
180
+ "title": "JS107 - Arrays & Objects Basics",
181
+ "lesson": "JS107",
182
+ "series": "javascript",
183
+ "shortTitle": "Arrays & Objects Basics",
184
+ "description": "Learn how to store and organize data in JavaScript using arrays and objects, the two fundamental data structures in modern applications.",
185
+ "date": "2023-02-12",
186
+ "readingMinutes": 2,
187
+ "body": "Arrays and objects are the most commonly used data structures in JavaScript. \nThey allow you to store multiple values and organize your data effectively.\n\n## Arrays\n\nAn array stores a list of values. \nValues can be numbers, strings, objects, or even other arrays.\n\n```js\nlet numbers = [1, 2, 3, 4];\nlet fruits = [\"apple\", \"banana\", \"orange\"];\n```\n\nAccessing array items:\n\n```js\nconsole.log(fruits[0]); // apple\nconsole.log(fruits[2]); // orange\n```\n\nUpdating array items:\n\n```js\nfruits[1] = \"kiwi\";\n```\n\n---\n\n## Array Methods\n\nJavaScript includes many built-in methods.\n\n```js\nlet items = [\"a\", \"b\", \"c\"];\n\nitems.push(\"d\"); // [\"a\", \"b\", \"c\", \"d\"]\nitems.pop(); // removes last item\nitems.shift(); // removes first item\nitems.unshift(\"z\"); // adds to the beginning\n```\n\nModern array helpers:\n\n```js\nitems.forEach(item => console.log(item));\n\nlet uppercased = items.map(item => item.toUpperCase());\n\nlet filtered = items.filter(item => item !== \"b\");\n```\n\n---\n\n## Objects\n\nObjects store data in key-value pairs.\n\n```js\nlet user = {\n name: \"Emre\",\n age: 30,\n city: \"Antalya\"\n};\n```\n\nAccessing values:\n\n```js\nconsole.log(user.name);\nconsole.log(user['city']);\n```\n\nUpdating properties:\n\n```js\nuser.age = 31;\nuser.country = \"Turkey\";\n```\n\n---\n\n## Nested Objects and Arrays\n\nObjects can contain arrays and arrays can contain objects.\n\n```js\nlet product = {\n title: \"Phone\",\n price: 12000,\n colors: [\"black\", \"white\"],\n seller: {\n name: \"TechStore\",\n rating: 4.8\n }\n};\n```\n\nAccessing nested values:\n\n```js\nconsole.log(product.colors[1]); // white\nconsole.log(product.seller.name); // TechStore\n```\n\n---\n\n## Object Methods\n\nObjects can also contain functions.\n\n```js\nlet person = {\n name: \"Emre\",\n greet() {\n console.log(\"Hello, \" + this.name);\n }\n};\n\nperson.greet(); // Hello, Emre\n```\n\n---\n\n## Destructuring (ES6)\n\nDestructuring allows you to extract values quickly.\n\n```js\nlet {name, city} = user;\nconsole.log(name); // Emre\n```\n\nArray destructuring:\n\n```js\nlet [first, second] = fruits;\n```\n\n---\n\n## Spread Operator\n\n```js\nlet extended = [...numbers, 5, 6];\nlet clonedUser = {...user};\n```\n\nSpread makes copying and merging easy.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- How arrays store ordered lists \n- Common array methods \n- How objects store key-value pairs \n- Nested objects and arrays \n- Object methods and this keyword \n- Destructuring and spread operator \n\nIn the next lesson, we will explore **loops and iteration** to work efficiently with lists of data.\n\n---\n"
188
+ },
189
+ {
190
+ "slug": "javascript-loops-iteration",
191
+ "title": "JS108 - Loops & Iteration",
192
+ "lesson": "JS108",
193
+ "series": "javascript",
194
+ "shortTitle": "Loops & Iteration",
195
+ "description": "Learn how to repeat actions in JavaScript using for, while, do-while, for...of, and forEach loops to iterate through data.",
196
+ "date": "2023-02-18",
197
+ "readingMinutes": 2,
198
+ "body": "Loops allow you to repeat actions and process lists of data efficiently. \nJavaScript provides several loop types, each with different use cases.\n\n## for Loop\n\nThe classic for loop runs a block of code a specific number of times.\n\n```js\nfor (let i = 0; i < 5; i++) {\n console.log(\"Count: \" + i);\n}\n```\n\n---\n\n## while Loop\n\nRuns as long as the condition is true.\n\n```js\nlet n = 0;\n\nwhile (n < 3) {\n console.log(\"n is \" + n);\n n++;\n}\n```\n\n---\n\n## do-while Loop\n\nRuns at least once even if the condition is false.\n\n```js\nlet x = 5;\n\ndo {\n console.log(x);\n x--;\n} while (x > 0);\n```\n\n---\n\n## for...of Loop\n\nUsed for iterating over arrays or iterable objects.\n\n```js\nlet fruits = [\"apple\", \"banana\", \"orange\"];\n\nfor (let fruit of fruits) {\n console.log(fruit);\n}\n```\n\n---\n\n## forEach Method\n\nA cleaner way to loop through arrays.\n\n```js\nfruits.forEach(function(item) {\n console.log(item);\n});\n```\n\nWith arrow functions:\n\n```js\nfruits.forEach(item => console.log(item));\n```\n\n---\n\n## Looping Through Objects\n\nObjects are not directly iterable. \nUse for...in to loop through keys.\n\n```js\nlet user = {\n name: \"Emre\",\n age: 30,\n city: \"Antalya\"\n};\n\nfor (let key in user) {\n console.log(key + \": \" + user[key]);\n}\n```\n\n---\n\n## Breaking and Continuing Loops\n\n```js\nfor (let i = 0; i < 10; i++) {\n if (i === 5) break;\n console.log(i);\n}\n```\n\ncontinue skips to the next iteration:\n\n```js\nfor (let i = 0; i < 5; i++) {\n if (i === 2) continue;\n console.log(i);\n}\n```\n\n---\n\n## Infinite Loops (Avoid)\n\nA loop runs forever if the condition never becomes false.\n\n```js\nwhile (true) {\n // This never stops!\n}\n```\n\nAlways ensure loop conditions update correctly.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- for, while, and do-while loops \n- for...of and for...in \n- forEach array iteration \n- How to break and continue loops \n- How to avoid infinite loops \n\nIn the next lesson, we will learn **DOM Manipulation** — how JavaScript interacts with HTML elements.\n\n---\n"
199
+ },
200
+ {
201
+ "slug": "javascript-dom-manipulation-basics",
202
+ "title": "JS109 - DOM Manipulation Basics",
203
+ "lesson": "JS109",
204
+ "series": "javascript",
205
+ "shortTitle": "DOM Manipulation Basics",
206
+ "description": "Learn how to select, modify, and interact with HTML elements using JavaScript's DOM API.",
207
+ "date": "2023-02-23",
208
+ "readingMinutes": 1,
209
+ "body": "The DOM (Document Object Model) allows JavaScript to interact with web pages. \nIt represents the structure of an HTML document as a tree that JavaScript can read and modify.\n\n## Selecting Elements\n\nJavaScript provides several methods to select HTML elements.\n\n### querySelector\n\n```js\nconst title = document.querySelector(\"h1\");\n```\n\n### querySelectorAll\n\n```js\nconst items = document.querySelectorAll(\".item\");\n```\n\n### getElementById\n\n```js\nconst box = document.getElementById(\"container\");\n```\n\n---\n\n## Changing Text Content\n\n```js\nconst heading = document.querySelector(\"h1\");\nheading.textContent = \"New Title\";\n```\n\n---\n\n## Changing Inner HTML\n\n```js\nheading.innerHTML = \"<span>Hello</span>\";\n```\n\n---\n\n## Modifying Styles\n\n```js\nheading.style.color = \"red\";\nheading.style.fontSize = \"24px\";\n```\n\n---\n\n## Working With Classes\n\n```js\nheading.classList.add(\"active\");\nheading.classList.remove(\"hidden\");\nheading.classList.toggle(\"dark\");\n```\n\n---\n\n## Creating and Adding Elements\n\n```js\nconst newItem = document.createElement(\"li\");\nnewItem.textContent = \"New list item\";\n\nconst list = document.querySelector(\"ul\");\nlist.appendChild(newItem);\n```\n\n---\n\n## Removing Elements\n\n```js\nnewItem.remove();\n```\n\n---\n\n## Handling Attributes\n\n```js\nconst img = document.querySelector(\"img\");\n\nimg.setAttribute(\"alt\", \"A beautiful photo\");\nimg.getAttribute(\"src\");\nimg.removeAttribute(\"title\");\n```\n\n---\n\n## DOM Tree Navigation\n\n```js\nelement.parentNode \nelement.children \nelement.firstChild \nelement.lastChild \n```\n\nUseful for exploring or modifying structure.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- How the DOM works \n- How to select elements \n- How to update text, HTML, styles \n- How to work with classes and attributes \n- How to create, insert, and remove elements \n- How to navigate the DOM tree \n\nIn the next lesson, we will explore **Events and Event Listeners** — making your pages interactive.\n\n---\n"
210
+ },
211
+ {
212
+ "slug": "javascript-events-event-listeners",
213
+ "title": "JS110 - Events & Event Listeners",
214
+ "lesson": "JS110",
215
+ "series": "javascript",
216
+ "shortTitle": "Events & Event Listeners",
217
+ "description": "Learn how JavaScript handles user interactions through events like click, input, and keydown using addEventListener.",
218
+ "date": "2023-02-27",
219
+ "readingMinutes": 2,
220
+ "body": "Events allow your website to react to user actions such as clicks, scrolling, typing, or mouse movement. \nJavaScript listens for these actions and runs specific functions when they occur.\n\n## What Is an Event?\n\nAn event is any interaction that happens in the browser. \nCommon events include:\n\n- click \n- input \n- submit \n- keydown \n- mouseover \n- scroll \n\n---\n\n## addEventListener\n\nThe primary way to listen for events is using addEventListener.\n\n```js\nconst button = document.querySelector(\"button\");\n\nbutton.addEventListener(\"click\", function() {\n console.log(\"Button clicked\");\n});\n```\n\n---\n\n## Using Arrow Functions\n\n```js\nbutton.addEventListener(\"click\", () => {\n console.log(\"Clicked!\");\n});\n```\n\n---\n\n## Getting Event Information\n\nEvery event listener receives an event object.\n\n```js\nbutton.addEventListener(\"click\", function(event) {\n console.log(event.target);\n});\n```\n\nCommon event properties:\n\n- event.target \n- event.type \n- event.key (for keyboard events)\n\n---\n\n## Input Events\n\n```js\nconst input = document.querySelector(\"input\");\n\ninput.addEventListener(\"input\", function(e) {\n console.log(\"Typed: \" + e.target.value);\n});\n```\n\n---\n\n## Keydown Events\n\n```js\ndocument.addEventListener(\"keydown\", function(e) {\n console.log(\"Key pressed: \" + e.key);\n});\n```\n\n---\n\n## Preventing Default Behavior\n\nUseful for forms and links.\n\n```js\nconst form = document.querySelector(\"form\");\n\nform.addEventListener(\"submit\", function(e) {\n e.preventDefault();\n console.log(\"Form blocked\");\n});\n```\n\n---\n\n## Event Bubbling (Default Behavior)\n\nEvents bubble from the target element up through its parents.\n\n```html\n<div id=\"parent\">\n <button id=\"child\">Click Me!</button>\n</div>\n```\n\n```js\ndocument.getElementById(\"parent\").addEventListener(\"click\", () => {\n console.log(\"Parent clicked\");\n});\n\ndocument.getElementById(\"child\").addEventListener(\"click\", () => {\n console.log(\"Child clicked\");\n});\n```\n\nClicking the button triggers both listeners unless stopped.\n\n---\n\n## Stopping Event Propagation\n\n```js\ndocument.getElementById(\"child\").addEventListener(\"click\", function(e) {\n e.stopPropagation();\n console.log(\"Only child triggered\");\n});\n```\n\n---\n\n## Event Delegation\n\nEfficient way to handle many similar elements.\n\n```js\ndocument.addEventListener(\"click\", function(e) {\n if (e.target.matches(\".item\")) {\n console.log(\"Item clicked: \" + e.target.textContent);\n }\n});\n```\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What events are \n- How to use addEventListener \n- How to read event information \n- Input and keyboard events \n- How bubbling works \n- How to stop propagation \n- Event delegation techniques \n\nIn the next lesson, we will explore the **Fetch API** and learn how JavaScript communicates with external servers.\n\n---\n"
221
+ },
222
+ {
223
+ "slug": "javascript-fetch-api-basics",
224
+ "title": "JS111 - Fetch API Basics",
225
+ "lesson": "JS111",
226
+ "series": "javascript",
227
+ "shortTitle": "Fetch API Basics",
228
+ "description": "Learn how to make HTTP requests in JavaScript using the Fetch API to load data from servers and work with JSON responses.",
229
+ "date": "2023-03-04",
230
+ "readingMinutes": 2,
231
+ "body": "The Fetch API allows JavaScript to request data from servers. \nIt is widely used for loading content, submitting forms, and building dynamic web applications.\n\n## Basic Fetch Request\n\nA simple request to load JSON data:\n\n```js\nfetch(\"https://example.com/data.json\")\n .then(response => response.json())\n .then(data => console.log(data))\n .catch(error => console.log(error));\n```\n\nFetch returns a **promise** that resolves with a Response object.\n\n---\n\n## Using async/await\n\nModern JavaScript uses async/await for cleaner syntax:\n\n```js\nasync function loadData() {\n try {\n const response = await fetch(\"https://example.com/users\");\n const data = await response.json();\n console.log(data);\n } catch (error) {\n console.log(\"Error: \", error);\n }\n}\n```\n\n---\n\n## Sending POST Requests\n\nFetch can also send data to a server:\n\n```js\nfetch(\"https://example.com/api/create\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify({\n name: \"Emre\",\n age: 30\n })\n})\n```\n\n---\n\n## Handling Errors\n\nFetch does not automatically throw errors for non-200 responses. \nYou must check status manually.\n\n```js\nconst response = await fetch(...);\n\nif (!response.ok) {\n throw new Error(\"Request failed\");\n}\n```\n\n---\n\n## Working With Text Responses\n\n```js\nfetch(\"/hello.txt\")\n .then(res => res.text())\n .then(txt => console.log(txt));\n```\n\n---\n\n## Chaining Multiple Fetch Calls\n\n```js\nfetch(\"/api/user\")\n .then(res => res.json())\n .then(user => fetch(`/api/posts/${user.id}`))\n .then(res => res.json())\n .then(posts => console.log(posts));\n```\n\n---\n\n## Aborting Requests (AbortController)\n\n```js\nconst controller = new AbortController();\n\nfetch(\"/slow-request\", { signal: controller.signal });\n\ncontroller.abort();\n```\n\nUseful for cancelling long or unwanted requests.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- How fetch works \n- How to use async/await for cleaner code \n- How to send POST requests \n- How to handle errors \n- How to work with text and JSON responses \n- How to abort fetch requests \n\nIn the next lesson, we will explore **ES6+ Essentials** — modern JavaScript features used in everyday development.\n\n---\n"
232
+ },
233
+ {
234
+ "slug": "javascript-es6-essentials",
235
+ "title": "JS112 - ES6+ Essentials",
236
+ "lesson": "JS112",
237
+ "series": "javascript",
238
+ "shortTitle": "ES6+ Essentials",
239
+ "description": "Learn the most important modern JavaScript features including let/const, template literals, destructuring, spread operator, arrow functions, and modules.",
240
+ "date": "2023-03-10",
241
+ "readingMinutes": 2,
242
+ "body": "Modern JavaScript (ES6 and beyond) introduced powerful new features that make code cleaner, faster, and easier to maintain. \nThis lesson covers the most essential ES6+ features you will use every day.\n\n## 1. let and const\n\nModern replacements for var.\n\n```js\nlet age = 30;\nconst name = \"Emre\";\n```\n\n- let can be reassigned\n- const cannot be reassigned\n\n---\n\n## 2. Template Literals\n\nUse backticks to embed variables inside strings.\n\n```js\nlet city = \"Antalya\";\nlet msg = `Hello from ${city}`;\n```\n\nSupports multi-line strings:\n\n```js\nlet text = `\nLine 1\nLine 2\n`;\n```\n\n---\n\n## 3. Destructuring\n\nExtract values from arrays or objects easily.\n\n### Object destructuring\n\n```js\nconst user = {\n name: \"Emre\",\n age: 30,\n};\n\nconst { name, age } = user;\n```\n\n### Array destructuring\n\n```js\nconst colors = [\"red\", \"green\", \"blue\"];\nconst [first, second] = colors;\n```\n\n---\n\n## 4. Spread Operator\n\nUsed for copying or merging arrays and objects.\n\n### Copy an array\n\n```js\nconst arr = [1, 2, 3];\nconst copy = [...arr];\n```\n\n### Merge arrays\n\n```js\nconst merged = [...arr, 4, 5];\n```\n\n### Copy an object\n\n```js\nconst cloned = { ...user };\n```\n\n---\n\n## 5. Arrow Functions\n\nShorter and more modern function syntax.\n\n```js\nconst greet = () => console.log(\"Hello\");\n```\n\nWith parameters:\n\n```js\nconst add = (a, b) => a + b;\n```\n\n---\n\n## 6. Default Parameters\n\n```js\nfunction welcome(name = \"Guest\") {\n console.log(\"Hello, \" + name);\n}\n```\n\n---\n\n## 7. Classes (OOP in JS)\n\n```js\nclass Person {\n constructor(name, age) {\n this.name = name;\n this.age = age;\n }\n\n greet() {\n console.log(\"Hello I'm \" + this.name);\n }\n}\n\nconst p = new Person(\"Emre\", 30);\np.greet();\n```\n\n---\n\n## 8. Modules (import / export)\n\nUsed to split code into reusable files.\n\n### Export\n\n```js\nexport const PI = 3.14;\n```\n\n### Import\n\n```js\nimport { PI } from \"./math.js\";\n```\n\nModules help organize large codebases.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- let and const\n- Template literals\n- Destructuring\n- Spread operator\n- Arrow functions\n- Default parameters\n- Classes\n- Modules\n\nWith this final lesson, your **JavaScript Beginners Course** is complete.\nYou are now ready to build interactive web applications and continue with more advanced JS topics!\n\n---\n"
243
+ },
244
+ {
245
+ "slug": "introduction-to-react",
246
+ "title": "REACT101 - Introduction to React",
247
+ "lesson": "REACT101",
248
+ "series": "react",
249
+ "shortTitle": "Introduction to React",
250
+ "description": "Learn what React is, why it was created, and how it helps developers build fast, scalable, and maintainable user interfaces.",
251
+ "date": "2023-06-15",
252
+ "readingMinutes": 2,
253
+ "body": "React is one of the most popular JavaScript libraries for building user interfaces. \nIn this lesson, you will learn **what React is**, **why it exists**, and **what problems it solves** compared to traditional JavaScript development.\n\n## What Is React?\n\nReact is an **open-source JavaScript library** created by Facebook for building user interfaces. \nIt focuses on the **view layer** of an application and allows developers to build reusable UI components.\n\nKey characteristics of React:\n\n- Component-based architecture \n- Declarative UI \n- Efficient rendering using Virtual DOM \n- Strong ecosystem and community \n\nReact does not replace JavaScript — it **extends** it.\n\n---\n\n## Why Was React Created?\n\nBefore React, developers manipulated the DOM directly using JavaScript or libraries like jQuery. \nAs applications grew larger, this approach caused problems:\n\n- Complex and hard-to-maintain code \n- Manual DOM updates \n- Poor performance \n- Difficult state management \n\nReact was created to solve these issues by introducing a **component-driven and state-based model**.\n\n---\n\n## Single Page Applications (SPA)\n\nReact is commonly used to build **Single Page Applications**.\n\nIn a SPA:\n\n- The page loads once \n- JavaScript updates the UI dynamically \n- No full page reloads \n- Faster and smoother user experience \n\nReact updates only the parts of the page that change instead of reloading everything.\n\n---\n\n## Declarative vs Imperative Code\n\n### Imperative approach (Vanilla JS)\n\nYou tell the browser **how** to update the UI step by step.\n\n### Declarative approach (React)\n\nYou describe **what the UI should look like** based on the current state.\n\nReact handles the DOM updates automatically when the state changes.\n\nThis makes code:\n\n- Easier to read \n- Easier to debug \n- Easier to scale \n\n---\n\n## Component-Based Architecture\n\nIn React, everything is built using **components**.\n\nA component:\n\n- Is a reusable piece of UI \n- Has its own logic and structure \n- Can receive data (props) \n- Can manage its own state \n\nExamples of components:\n\n- Button \n- Header \n- ProductCard \n- Navbar \n\nLarge applications are built by combining many small components.\n\n---\n\n## Virtual DOM Explained\n\nReact uses a **Virtual DOM** to improve performance.\n\nHow it works:\n\n1. React creates a virtual representation of the UI \n2. When state changes, React compares the new Virtual DOM with the old one \n3. Only the differences are applied to the real DOM \n\nThis process is called **diffing** and makes UI updates fast and efficient.\n\n---\n\n## When Should You Use React?\n\nReact is a great choice when:\n\n- Your UI is complex and dynamic \n- You need reusable components \n- Your app has many user interactions \n- You want long-term maintainability \n\nReact may be unnecessary for very small or static websites.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What React is \n- Why React was created \n- What problems it solves \n- What a Single Page Application is \n- The difference between imperative and declarative code \n- The basics of component-based architecture \n- How the Virtual DOM works \n\nIn the next lesson, we will **set up the React development environment** and create your first React project.\n\n---\n"
254
+ },
255
+ {
256
+ "slug": "react-environment-setup",
257
+ "title": "REACT102 - React Environment Setup",
258
+ "lesson": "REACT102",
259
+ "series": "react",
260
+ "shortTitle": "React Environment Setup",
261
+ "description": "Learn how to set up a modern React development environment using Node.js, npm, and Vite to create your first React application.",
262
+ "date": "2023-06-18",
263
+ "readingMinutes": 2,
264
+ "body": "Before writing React code, you need a proper development environment. \nIn this lesson, you will learn how to install the required tools and create a clean, modern React project.\n\n## Prerequisites for React\n\nTo work with React, you need the following tools installed on your system:\n\n- Node.js \n- npm (Node Package Manager) \n- A code editor (VS Code recommended) \n- A modern web browser \n\nReact itself runs in the browser, but the development tools require Node.js.\n\n---\n\n## Installing Node.js\n\nNode.js allows you to run JavaScript outside the browser and manage project dependencies.\n\nDownload Node.js from the official website:\n\nhttps://nodejs.org\n\nAfter installation, verify it in the terminal:\n\n```bash\nnode -v\nnpm -v\n```\n\nYou should see version numbers for both commands.\n\n---\n\n## Choosing a React Setup Tool\n\nThere are multiple ways to create a React project. \nThe most popular options are:\n\n- Create React App (CRA) \n- Vite \n\nFor this course, we will use **Vite** because it is:\n\n- Faster than CRA \n- Lightweight \n- Modern and flexible \n- Widely adopted \n\n---\n\n## Creating a React App with Vite\n\nUse the following command to create a new React project:\n\n```bash\nnpm create vite@latest my-react-app\n```\n\nWhen prompted:\n\n- Select **React** \n- Choose **JavaScript** \n\nNavigate into the project folder:\n\n```bash\ncd my-react-app\nnpm install\n```\n\nStart the development server:\n\n```bash\nnpm run dev\n```\n\nYour React app will open in the browser.\n\n---\n\n## Project Structure Explained\n\nA typical Vite React project includes:\n\n- src/ = application source code \n- main.jsx = entry point \n- App.jsx = root component \n- index.html = main HTML file \n- package.json = project configuration \n\nUnderstanding this structure helps you navigate React projects confidently.\n\n---\n\n## Running and Stopping the App\n\nTo run the app:\n\n```bash\nnpm run dev\n```\n\nTo stop the server:\n\n- Press **Ctrl + C** in the terminal \n\nAny file change automatically reloads the browser.\n\n---\n\n## Recommended VS Code Extensions\n\nHelpful extensions for React development:\n\n- ES7+ React Snippets \n- Prettier \n- ESLint \n- Auto Rename Tag \n\nThese tools improve code quality and developer experience.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What tools are required for React development \n- How to install Node.js and npm \n- Why Vite is a great choice for React \n- How to create and run a React project \n- Basic React project structure \n\nIn the next lesson, we will explore **JSX** and learn how React describes UI using JavaScript syntax.\n\n---\n"
265
+ },
266
+ {
267
+ "slug": "react-jsx-fundamentals",
268
+ "title": "REACT103 - JSX Fundamentals",
269
+ "lesson": "REACT103",
270
+ "series": "react",
271
+ "shortTitle": "JSX Fundamentals",
272
+ "description": "Learn what JSX is, why React uses it, and how to write dynamic user interfaces using JavaScript expressions inside JSX.",
273
+ "date": "2023-06-21",
274
+ "readingMinutes": 2,
275
+ "body": "JSX is one of the most important concepts in React and often the most confusing for beginners. \nIn this lesson, you will learn **what JSX is**, **why it exists**, and **how to use it correctly** to build dynamic user interfaces.\n\n## What Is JSX?\n\nJSX stands for **JavaScript XML**. \nIt is a syntax extension that allows you to write HTML-like code inside JavaScript files.\n\nAlthough JSX looks like HTML, it is **not HTML**. \nJSX is transformed into regular JavaScript function calls before running in the browser.\n\n---\n\n## Why React Uses JSX\n\nJSX makes UI code easier to read and maintain by keeping structure and logic together.\n\nWithout JSX, UI code becomes verbose and harder to understand. \nWith JSX, React components remain clear and expressive.\n\nJSX allows you to:\n\n- Combine logic and markup \n- Embed JavaScript expressions in UI \n- Create readable component structures \n\n---\n\n## JSX Behind the Scenes\n\nJSX is converted into JavaScript using a build tool such as Babel.\n\nThis JSX code:\n\n```jsx\nconst element = <h1>Hello React</h1>;\n```\n\nIs transformed into:\n\n```js\nconst element = React.createElement(\"h1\", null, \"Hello React\");\n```\n\nThis is why JSX must be valid JavaScript.\n\n---\n\n## JSX Syntax Rules\n\nJSX follows specific rules:\n\n- JSX must return **one parent element** \n- All tags must be properly closed \n- Use **camelCase** for attributes \n- Use **className** instead of class \n\nExample:\n\n```jsx\nfunction App() {\n return (\n <div className=\"container\">\n <h1>Welcome</h1>\n <p>React JSX example</p>\n </div>\n );\n}\n```\n\n---\n\n## Embedding JavaScript in JSX\n\nYou can embed JavaScript expressions using curly braces {}.\n\n```jsx\nconst name = \"Emre\";\n\nfunction Greeting() {\n return <h2>Hello, {name}</h2>;\n}\n```\n\nValid expressions include:\n\n- Variables \n- Function calls \n- Mathematical operations \n- Ternary expressions \n\nStatements like if or for are **not allowed** directly inside JSX.\n\n---\n\n## Conditional Rendering in JSX\n\nUse ternary operators for conditions.\n\n```jsx\nfunction Status() {\n const isLoggedIn = true;\n\n return (\n <p>{isLoggedIn ? \"Welcome back\" : \"Please log in\"}</p>\n );\n}\n```\n\n---\n\n## JSX and Styling\n\nInline styles are written as JavaScript objects.\n\n```jsx\nconst style = {\n color: \"blue\",\n fontSize: \"18px\"\n};\n\nfunction Title() {\n return <h1 style={style}>Styled Title</h1>;\n}\n```\n\n---\n\n## JSX Comments\n\nUse JavaScript comments inside curly braces.\n\n```jsx\nfunction App() {\n return (\n <div>\n {/* This is a JSX comment */}\n <h1>Hello JSX</h1>\n </div>\n );\n}\n```\n\n---\n\n## Common JSX Mistakes\n\n- Forgetting to close tags \n- Using class instead of className \n- Returning multiple elements without a wrapper \n- Writing statements inside JSX \n\nUnderstanding these rules prevents many beginner errors.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What JSX is and why it exists \n- How JSX is transformed into JavaScript \n- Core JSX syntax rules \n- How to embed JavaScript expressions \n- Conditional rendering basics \n- Styling and comments in JSX \n\nIn the next lesson, we will explore **React Components** and learn how to structure applications using reusable building blocks.\n\n---\n"
276
+ },
277
+ {
278
+ "slug": "react-components-basics",
279
+ "title": "REACT104 - Components in React",
280
+ "lesson": "REACT104",
281
+ "series": "react",
282
+ "shortTitle": "Components in React",
283
+ "description": "Learn what React components are, how to create functional components, and how to structure applications using reusable UI building blocks.",
284
+ "date": "2023-06-24",
285
+ "readingMinutes": 2,
286
+ "body": "Components are the core building blocks of every React application. \nIn this lesson, you will learn **what components are**, **why they exist**, and **how to create and organize them properly**.\n\n## What Is a Component?\n\nA component is a **reusable piece of UI** that encapsulates structure, logic, and presentation. \nReact applications are built by combining many small components into larger ones.\n\nExamples of components:\n\n- Button \n- Header \n- Footer \n- ProductCard \n- Navbar \n\nEach component represents a specific responsibility in the UI.\n\n---\n\n## Functional Components\n\nModern React uses **functional components** instead of class components.\n\nA functional component is simply a JavaScript function that returns JSX.\n\n```jsx\nfunction Hello() {\n return <h1>Hello React</h1>;\n}\n```\n\nComponents must start with a **capital letter** so React can distinguish them from HTML elements.\n\n---\n\n## Using Components\n\nOnce defined, components can be used like HTML tags.\n\n```jsx\nfunction App() {\n return (\n <div>\n <Hello />\n <Hello />\n </div>\n );\n}\n```\n\nThis allows you to reuse the same UI logic multiple times.\n\n---\n\n## Component File Structure\n\nA common pattern is **one component per file**.\n\nExample structure:\n\n- src/ \n - components/ \n - Header.jsx \n - Footer.jsx \n - Button.jsx \n\nThis keeps your codebase organized and scalable.\n\n---\n\n## Returning Multiple Elements\n\nReact components must return **a single parent element**.\n\nUse a wrapper element:\n\n```jsx\nfunction Card() {\n return (\n <div>\n <h2>Title</h2>\n <p>Description</p>\n </div>\n );\n}\n```\n\nOr use **React Fragment**:\n\n```jsx\nfunction Card() {\n return (\n <>\n <h2>Title</h2>\n <p>Description</p>\n </>\n );\n}\n```\n\nFragments avoid unnecessary DOM elements.\n\n---\n\n## Component Composition\n\nComponents can include other components inside them.\n\n```jsx\nfunction Layout() {\n return (\n <div>\n <Header />\n <main>Content here</main>\n <Footer />\n </div>\n );\n}\n```\n\nThis is called **component composition** and is a fundamental React pattern.\n\n---\n\n## Single Responsibility Principle\n\nEach component should have **one clear responsibility**.\n\nBad example:\n\n- Component handles layout \n- Fetches data \n- Manages form logic \n- Styles UI \n\nGood approach:\n\n- Separate components for layout \n- Separate components for logic \n- Smaller, focused components \n\nThis makes components easier to test and maintain.\n\n---\n\n## Naming Conventions\n\nRecommended conventions:\n\n- Component names use **PascalCase** \n- File names match component names \n- Keep names descriptive but concise \n\nExamples:\n\n- UserCard \n- ProductList \n- LoginForm \n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What React components are \n- How to write functional components \n- How to use and reuse components \n- Component file organization \n- Returning multiple elements safely \n- Component composition \n- Best practices for naming and structure \n\nIn the next lesson, we will explore **Props** and learn how components communicate with each other.\n\n---\n"
287
+ },
288
+ {
289
+ "slug": "react-props-basics",
290
+ "title": "REACT105 - Props in React",
291
+ "lesson": "REACT105",
292
+ "series": "react",
293
+ "shortTitle": "Props in React",
294
+ "description": "Learn how to pass data between React components using props, understand one-way data flow, and apply best practices for reusable components.",
295
+ "date": "2023-06-27",
296
+ "readingMinutes": 2,
297
+ "body": "Props (short for properties) are the primary way to pass data **from one component to another** in React. \nIn this lesson, you will learn how props work, how to use them effectively, and why they are essential for building reusable components.\n\n## What Are Props?\n\nProps are **read-only inputs** passed to a component by its parent. \nThey allow components to be dynamic and configurable.\n\nThink of props as **function parameters** for components.\n\n---\n\n## Passing Props to a Component\n\nYou can pass props to a component using attributes.\n\n```jsx\nfunction App() {\n return <Greeting name=\"Emre\" />;\n}\n```\n\nReceiving props in the child component:\n\n```jsx\nfunction Greeting(props) {\n return <h2>Hello, {props.name}</h2>;\n}\n```\n\nThis makes the component reusable with different values.\n\n---\n\n## Props Destructuring\n\nDestructuring makes props easier to work with.\n\n```jsx\nfunction Greeting({ name }) {\n return <h2>Hello, {name}</h2>;\n}\n```\n\nThis is the most common pattern in modern React code.\n\n---\n\n## Passing Multiple Props\n\nComponents can receive multiple props.\n\n```jsx\n<UserCard \n username=\"ekurt\" \n age={30} \n city=\"Antalya\" \n/>\n```\n\nUsing them:\n\n```jsx\nfunction UserCard({ username, age, city }) {\n return (\n <div>\n <h3>{username}</h3>\n <p>Age: {age}</p>\n <p>City: {city}</p>\n </div>\n );\n}\n```\n\n---\n\n## Props Are Read-Only\n\nProps **cannot be modified** inside a component.\n\nThis is **not allowed**:\n\n```jsx\nprops.name = \"New Name\";\n```\n\nReact enforces **one-way data flow**:\n\nParent → Child \n\nIf data needs to change, it must be handled using **state** in the parent component.\n\n---\n\n## Passing Functions as Props\n\nProps can also be functions. \nThis allows child components to communicate with parents.\n\n```jsx\nfunction App() {\n function handleClick() {\n console.log(\"Button clicked\");\n }\n\n return <Button onClick={handleClick} />;\n}\n```\n\nChild component:\n\n```jsx\nfunction Button({ onClick }) {\n return <button onClick={onClick}>Click Me</button>;\n}\n```\n\nThis pattern is extremely common in React applications.\n\n---\n\n## Default Props\n\nYou can define default values for props.\n\n```jsx\nfunction Avatar({ size = 40 }) {\n return <img width={size} height={size} />;\n}\n```\n\nIf size is not provided, React uses the default value.\n\n---\n\n## Children Prop\n\nEvery component automatically receives a **children** prop.\n\n```jsx\nfunction Card({ children }) {\n return <div className=\"card\">{children}</div>;\n}\n```\n\nUsage:\n\n```jsx\n<Card>\n <h2>Title</h2>\n <p>Description</p>\n</Card>\n```\n\nThis allows flexible and composable layouts.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What props are and why they exist \n- How to pass and receive props \n- Props destructuring \n- One-way data flow in React \n- Passing functions as props \n- Default props \n- The children prop \n\nIn the next lesson, we will explore **state** and learn how React components manage dynamic data using the useState hook.\n\n---\n"
298
+ },
299
+ {
300
+ "slug": "react-state-usestate-hook",
301
+ "title": "REACT106 - State & useState Hook",
302
+ "lesson": "REACT106",
303
+ "series": "react",
304
+ "shortTitle": "State & useState Hook",
305
+ "description": "Learn what state is in React, why normal variables are not enough, and how to manage dynamic data using the useState hook.",
306
+ "date": "2023-06-30",
307
+ "readingMinutes": 2,
308
+ "body": "State is the heart of every interactive React application. \nIn this lesson, you will learn **what state is**, **why it exists**, and **how to manage it using the useState hook**.\n\n## What Is State?\n\nState represents **data that can change over time** inside a component. \nWhen state changes, React automatically **re-renders** the component to reflect the new data.\n\nExamples of state data:\n\n- Counter values \n- Form inputs \n- Toggle flags \n- API responses \n\n---\n\n## Why Not Use Normal Variables?\n\nNormal JavaScript variables do not trigger re-renders when they change.\n\nExample problem:\n\n```jsx\nlet count = 0;\n\nfunction Counter() {\n function increment() {\n count ++;\n }\n\n return <button onClick={increment}>{count}</button>;\n}\n```\n\nEven though count changes, React does not update the UI. \nThis is why **state is required**.\n\n---\n\n## Introducing useState\n\nuseState is a **React Hook** that lets you add state to functional components.\n\nBasic syntax:\n\n```jsx\nconst [state, setState] = useState(initialValue);\n```\n\nExample:\n\n```jsx\nimport { useState } from \"react\";\n\nfunction Counter() {\n const [count, setCount] = useState(0);\n\n return <button>{count}</button>;\n}\n```\n\n---\n\n## Updating State\n\nState should always be updated using the setter function.\n\n```jsx\nsetCount(count + 1);\n```\n\nReact schedules a re-render whenever state updates.\n\n---\n\n## Handling Events with State\n\n```jsx\nfunction Counter() {\n const [count, setCount] = useState(0);\n\n function increment() {\n setCount(count + 1);\n }\n\n return <button onClick={increment}>{count}</button>;\n}\n```\n\nNow the UI updates correctly on every click.\n\n---\n\n## Updating State Based on Previous State\n\nWhen state depends on its previous value, use a callback.\n\n```jsx\nsetCount(prev => prev + 1);\n```\n\nThis prevents bugs caused by stale state values.\n\n---\n\n## Multiple State Values\n\nYou can use useState multiple times in a component.\n\n```jsx\nconst [name, setName] = useState(\"\");\nconst [age, setAge] = useState(0);\n```\n\nEach state value is independent.\n\n---\n\n## State with Objects\n\nState can store objects, but updates must be immutable.\n\n```jsx\nconst [user, setUser] = useState({\n name: \"Emre\",\n age: 30\n});\n```\n\nUpdating safely:\n\n```jsx\nsetUser({\n ...user,\n age: 31\n});\n```\n\nNever mutate state directly.\n\n---\n\n## State with Arrays\n\n```jsx\nconst [items, setItems] = useState([]);\n```\n\nAdding items:\n\n```jsx\nsetItems([...items, \"new item\"]);\n```\n\n---\n\n## Common State Mistakes\n\n- Modifying state directly \n- Forgetting to use setter functions \n- Using state when props are enough \n- Overusing state \n\nUnderstanding state scope is key to clean React code.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What state is and why it exists \n- Why normal variables fail in React \n- How to use the useState hook \n- Updating state correctly \n- Handling events with state \n- Managing objects and arrays in state \n\nIn the next lesson, we will explore **handling events in React** and connect state with user interactions.\n\n---\n"
309
+ },
310
+ {
311
+ "slug": "react-handling-events",
312
+ "title": "REACT107 - Handling Events in React",
313
+ "lesson": "REACT107",
314
+ "series": "react",
315
+ "shortTitle": "Handling Events in React",
316
+ "description": "Learn how to handle user interactions in React using event handlers, synthetic events, and state updates to build interactive components.",
317
+ "date": "2023-07-03",
318
+ "readingMinutes": 3,
319
+ "body": "Handling events is how React applications become interactive. \nIn this lesson, you will learn how React handles events, how they differ from native JavaScript events, and how to connect them with state updates.\n\n## React Events Overview\n\nReact events are similar to DOM events, but they use a **synthetic event system** for consistency across browsers.\n\nCommon React events include:\n\n- onClick \n- onChange \n- onSubmit \n- onMouseEnter \n- onKeyDown \n\nEvent names use **camelCase** instead of lowercase.\n\n---\n\n## Basic Event Handling\n\nAttach event handlers using JSX attributes.\n\n```jsx\nfunction Button() {\n function handleClick() {\n console.log(\"Button clicked\");\n }\n\n return <button onClick={handleClick}>Click Me</button>;\n}\n```\n\nThe function reference is passed, not executed immediately.\n\n---\n\n## Inline Event Handlers\n\nYou can also define handlers inline.\n\n```jsx\n<button onClick={() => console.log(\"Clicked\")}>\n Click\n</button>\n```\n\nThis is useful for small logic but should be avoided for complex operations.\n\n---\n\n## Passing Arguments to Event Handlers\n\nTo pass arguments, use an arrow function.\n\n```jsx\nfunction Item({ id }) {\n function handleSelect(itemId) {\n console.log(itemId);\n }\n\n return <button onClick={() => handleSelect(id)}>Select</button>;\n}\n```\n\nDo not call the function directly inside JSX.\n\n---\n\n## Using State with Events\n\nEvents are commonly used to update state.\n\n```jsx\nfunction Counter() {\n const [count, setCount] = useState(0);\n\n function increment() {\n setCount(prev => prev + 1);\n }\n\n return <button onClick={increment}>{count}</button>;\n}\n```\n\nThis pattern connects user interaction with UI updates.\n\n---\n\n## Handling Input Events\n\nForm inputs use onChange to track user input.\n\n```jsx\nfunction InputExample() {\n const [value, setValue] = useState(\"\");\n\n function handleChange(e) {\n setValue(e.target.value);\n }\n\n return <input value={value} onChange={handleChange} />;\n}\n```\n\nReact uses **controlled components** to manage form data.\n\n---\n\n## Synthetic Events\n\nReact wraps native browser events into **SyntheticEvent** objects.\n\nAdvantages:\n\n- Cross-browser compatibility \n- Consistent API \n- Better performance \n\nSynthetic events behave like native events in most cases.\n\n---\n\n## Preventing Default Behavior\n\nUse preventDefault for forms and links.\n\n```jsx\nfunction Form() {\n function handleSubmit(e) {\n e.preventDefault();\n console.log(\"Form submitted\");\n }\n\n return <form onSubmit={handleSubmit}></form>;\n}\n```\n\nThis prevents page reloads in Single Page Applications.\n\n---\n\n## Event Bubbling in React\n\nEvents bubble up the component tree by default.\n\n```jsx\nfunction Parent() {\n return <div onClick={() => console.log(\"Parent\")}>\n <Child />\n </div>;\n}\n\nfunction Child() {\n return <button onClick={() => console.log(\"Child\")}>\n Click\n </button>;\n}\n```\n\nClicking the button triggers both events unless propagation is stopped.\n\n---\n\n## Stopping Event Propagation\n\n```jsx\nfunction Child() {\n function handleClick(e) {\n e.stopPropagation();\n console.log(\"Only child\");\n }\n\n return <button onClick={handleClick}>Click</button>;\n}\n```\n\nUse this carefully to avoid unexpected behavior.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- How React handles events \n- Common React event types \n- Attaching event handlers \n- Passing arguments to events \n- Updating state through events \n- Controlled inputs \n- Synthetic events \n- Event bubbling and propagation \n\nIn the next lesson, we will explore **conditional rendering** and learn how to display UI dynamically based on state.\n\n---\n"
320
+ },
321
+ {
322
+ "slug": "react-conditional-rendering",
323
+ "title": "REACT108 - Conditional Rendering",
324
+ "lesson": "REACT108",
325
+ "series": "react",
326
+ "shortTitle": "Conditional Rendering",
327
+ "description": "Learn how to render different UI states in React using conditions such as if statements, ternary operators, logical operators, and early returns.",
328
+ "date": "2023-07-06",
329
+ "readingMinutes": 2,
330
+ "body": "Conditional rendering allows React applications to display different UI based on **state** or **props**. \nIn this lesson, you will learn the most common and recommended patterns for rendering UI conditionally in React.\n\n## What Is Conditional Rendering?\n\nConditional rendering means showing or hiding parts of the UI depending on a condition.\n\nExamples include:\n\n- Showing a login button only when the user is logged out \n- Displaying a loading spinner while data is being fetched \n- Rendering error messages when something fails \n\nReact uses standard JavaScript logic for conditional rendering.\n\n---\n\n## Using if Statements\n\nYou can use if statements **outside JSX** to control what gets rendered.\n\n```jsx\nfunction Status({ isLoggedIn }) {\n if (isLoggedIn) {\n return <p>Welcome back</p>;\n }\n\n return <p>Please log in</p>;\n}\n```\n\nThis approach is clear and readable for simple conditions.\n\n---\n\n## Early Return Pattern\n\nReturning early helps avoid deeply nested JSX.\n\n```jsx\nfunction Message({ error }) {\n if (error) {\n return <p>Something went wrong</p>;\n }\n\n return <p>Everything looks good</p>;\n}\n```\n\nEarly returns improve code clarity.\n\n---\n\n## Ternary Operator\n\nThe ternary operator is commonly used inside JSX.\n\n```jsx\nfunction AuthMessage({ isLoggedIn }) {\n return (\n <p>{isLoggedIn ? \"Welcome\" : \"Please log in\"}</p>\n );\n}\n```\n\nUse ternaries for simple conditions only.\n\n---\n\n## Logical AND Operator ( && )\n\nThe logical AND operator renders content only when the condition is true.\n\n```jsx\nfunction Notification({ hasMessage }) {\n return (\n <div>\n {hasMessage && <p>You have a new message</p>}\n </div>\n );\n}\n```\n\nIf the condition is false, nothing is rendered.\n\n---\n\n## Conditional Rendering with State\n\nConditional rendering is often driven by state.\n\n```jsx\nfunction Loader() {\n const [loading, setLoading] = useState(true);\n\n return (\n <div>\n {loading ? <p>Loading...</p> : <p>Data loaded</p>}\n </div>\n );\n}\n```\n\nThis pattern is common in data-driven applications.\n\n---\n\n## Avoiding Common Mistakes\n\nCommon mistakes include:\n\n- Using if statements directly inside JSX \n- Overusing nested ternary operators \n- Forgetting to handle all UI states \n\nAlways consider:\n\n- Loading state \n- Error state \n- Empty state \n\n---\n\n## Conditional Rendering with Components\n\nYou can conditionally render entire components.\n\n```jsx\nfunction App({ showModal }) {\n return (\n <div>\n {showModal && <Modal />}\n </div>\n );\n}\n```\n\nThis keeps your UI modular and clean.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What conditional rendering is \n- Using if statements and early returns \n- Ternary operator usage \n- Logical AND rendering \n- Conditional rendering with state \n- Common pitfalls to avoid \n\nIn the next lesson, we will explore **rendering lists and keys** and learn how to display dynamic collections of data in React.\n\n---\n"
331
+ },
332
+ {
333
+ "slug": "react-rendering-lists-and-keys",
334
+ "title": "REACT109 - Rendering Lists & Keys",
335
+ "lesson": "REACT109",
336
+ "series": "react",
337
+ "shortTitle": "Rendering Lists & Keys",
338
+ "description": "Learn how to render dynamic lists in React using map, understand why keys are required, and apply best practices for performant list rendering.",
339
+ "date": "2023-07-09",
340
+ "readingMinutes": 3,
341
+ "body": "Rendering lists is a fundamental part of building real-world React applications. \nIn this lesson, you will learn how to display collections of data efficiently using map and how keys help React update the UI correctly.\n\n## Rendering Lists with map\n\nIn React, lists are rendered using the JavaScript map function.\n\n```jsx\nfunction FruitList() {\n const fruits = [\"Apple\", \"Banana\", \"Orange\"];\n\n return (\n <ul>\n {fruits.map(fruit => (\n <li>{fruit}</li>\n ))}\n </ul>\n );\n}\n```\n\nmap transforms each array item into a JSX element.\n\n---\n\n## Why map Instead of for Loops\n\nReact expects JSX expressions, not statements.\n\n- for loops are statements \n- map returns a new array \n\nThis makes map the correct and preferred choice for rendering lists.\n\n---\n\n## What Are Keys?\n\nKeys are **special attributes** used by React to identify elements in a list.\n\nThey help React:\n\n- Track which items changed \n- Optimize re-rendering \n- Avoid unnecessary DOM updates \n\nWithout keys, React cannot efficiently update the UI.\n\n---\n\n## Adding Keys to List Items\n\nKeys must be added to the **outermost element** inside map.\n\n```jsx\nfunction FruitList() {\n const fruits = [\"Apple\", \"Banana\", \"Orange\"];\n\n return (\n <ul>\n {fruits.map(fruit => (\n <li key={fruit}>{fruit}</li>\n ))}\n </ul>\n );\n}\n```\n\nEach key must be **unique** among siblings.\n\n---\n\n## Using IDs as Keys (Best Practice)\n\nThe best key is a **stable unique ID** from your data.\n\n```jsx\nconst users = [\n { id: 1, name: \"Emre\" },\n { id: 2, name: \"Ahmet\" }\n];\n\nfunction UserList() {\n return (\n <ul>\n {users.map(user => (\n <li key={user.id}>{user.name}</li>\n ))}\n </ul>\n );\n}\n```\n\nIDs ensure predictable rendering behavior.\n\n---\n\n## Why Not Use Index as Key\n\nUsing array index as a key can cause bugs.\n\nProblems include:\n\n- Incorrect item updates \n- Broken animations \n- Unexpected UI behavior \n\nIndex keys are acceptable **only for static lists that never change**.\n\n---\n\n## Rendering Components in Lists\n\nLists often render components instead of plain elements.\n\n```jsx\nfunction ProductList({ products }) {\n return (\n <div>\n {products.map(product => (\n <ProductCard \n key={product.id}\n product={product}\n />\n ))}\n </div>\n );\n}\n```\n\nEach component still requires a key.\n\n---\n\n## Conditional Lists\n\nYou may want to handle empty lists.\n\n```jsx\nfunction List({ items }) {\n if (items.length === 0) {\n return <p>No items found</p>;\n }\n\n return (\n <ul>\n {items.map(item => (\n <li key={item.id}>{item.name}</li>\n ))}\n </ul>\n );\n}\n```\n\nAlways consider the empty state.\n\n---\n\n## Performance Considerations\n\nGood key usage:\n\n- Improves rendering performance \n- Prevents unnecessary DOM updates \n- Makes React diffs predictable \n\nKeys are not accessible via props — they are used internally by React.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- How to render lists using map \n- Why keys are required \n- How to choose proper keys \n- Why index keys can be dangerous \n- Rendering components inside lists \n- Handling empty list states \n\nIn the next lesson, we will explore **styling in React** and learn different ways to apply styles to components.\n\n---\n"
342
+ },
343
+ {
344
+ "slug": "styling-in-react",
345
+ "title": "REACT110 - Styling in React",
346
+ "lesson": "REACT110",
347
+ "series": "react",
348
+ "shortTitle": "Styling in React",
349
+ "description": "Learn different ways to style React components including CSS files, inline styles, conditional classes, and best practices for maintainable UI styling.",
350
+ "date": "2023-07-12",
351
+ "readingMinutes": 2,
352
+ "body": "Styling is an essential part of building user interfaces. \nIn this lesson, you will learn **multiple ways to apply styles in React** and understand when to use each approach.\n\n## Styling Options in React\n\nReact does not enforce a single styling solution. \nCommon styling approaches include:\n\n- Regular CSS files \n- Inline styles \n- Conditional class names \n- CSS Modules (introductory concept) \n\nChoosing the right method depends on project size and complexity.\n\n---\n\n## Using Regular CSS Files\n\nThe simplest approach is using standard CSS files.\n\nExample file structure:\n\n- src/ \n - styles.css \n\nImporting CSS into a component:\n\n```jsx\nimport \"./styles.css\";\n```\n\nUsing class names:\n\n```jsx\nfunction Title() {\n return <h1 className=\"title\">Hello React</h1>;\n}\n```\n\nCSS files are global by default.\n\n---\n\n## Inline Styles\n\nInline styles are written as JavaScript objects.\n\n```jsx\nfunction Box() {\n const style = {\n backgroundColor: \"lightblue\",\n padding: \"16px\",\n borderRadius: \"8px\"\n };\n\n return <div style={style}>Styled Box</div>;\n}\n```\n\nInline styles:\n\n- Use camelCase properties \n- Do not support pseudo-classes \n- Are useful for dynamic styles \n\n---\n\n## Conditional Styling\n\nStyles often depend on state or props.\n\n```jsx\nfunction Button({ isActive }) {\n return (\n <button className={isActive ? \"btn active\" : \"btn\"}>\n Click\n </button>\n );\n}\n```\n\nThis allows dynamic UI feedback.\n\n---\n\n## Conditional Inline Styles\n\nInline styles can also be conditional.\n\n```jsx\nfunction Status({ online }) {\n return (\n <p style={{ color: online ? \"green\" : \"red\" }}>\n Status\n </p>\n );\n}\n```\n\nThis is useful for simple visual changes.\n\n---\n\n## CSS Modules (Intro)\n\nCSS Modules scope styles locally to components.\n\nExample file:\n\n- Button.module.css \n\nUsing CSS Modules:\n\n```jsx\nimport styles from \"./Button.module.css\";\n\nfunction Button() {\n return <button className={styles.primary}>Click</button>;\n}\n```\n\nThis prevents class name collisions in large projects.\n\n---\n\n## Styling Best Practices\n\nRecommended practices:\n\n- Keep styles close to components \n- Use meaningful class names \n- Avoid overly complex inline styles \n- Prefer CSS files or modules for large apps \n- Be consistent across the project \n\nClean styling improves maintainability.\n\n---\n\n## Common Styling Mistakes\n\nAvoid:\n\n- Mixing too many styling approaches \n- Hardcoding styles everywhere \n- Ignoring responsive design \n- Using inline styles for everything \n\nConsistency is key in UI development.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- Different styling approaches in React \n- How to use regular CSS files \n- How inline styles work \n- Conditional styling techniques \n- Introduction to CSS Modules \n- Styling best practices \n\nIn the next lesson, we will explore **useEffect and lifecycle basics** and learn how to handle side effects in React components.\n\n---\n"
353
+ },
354
+ {
355
+ "slug": "react-useeffect-lifecycle-basics",
356
+ "title": "REACT111 - useEffect & Lifecycle Basics",
357
+ "lesson": "REACT111",
358
+ "series": "react",
359
+ "shortTitle": "useEffect & Lifecycle Basics",
360
+ "description": "Learn how to handle side effects in React using the useEffect hook and understand basic component lifecycle concepts in functional components.",
361
+ "date": "2023-07-15",
362
+ "readingMinutes": 2,
363
+ "body": "Many React components need to perform **side effects** such as fetching data, subscribing to events, or updating the document title. \nIn this lesson, you will learn how to manage side effects using the **useEffect** hook and understand basic lifecycle behavior in React functional components.\n\n## What Is a Side Effect?\n\nA side effect is any operation that affects something **outside the component render process**.\n\nCommon side effects include:\n\n- Fetching data from an API \n- Setting up timers or intervals \n- Subscribing to events \n- Updating the document title \n- Manipulating browser APIs \n\nSide effects should not run during rendering.\n\n---\n\n## Introducing useEffect\n\nuseEffect is a React Hook used to run side effects in functional components.\n\nBasic syntax:\n\n```jsx\nimport { useEffect } from \"react\";\n\nuseEffect(() => {\n // side effect code\n});\n```\n\nBy default, useEffect runs **after every render**.\n\n---\n\n## Running useEffect Once (on Mount)\n\nTo run an effect only once when the component mounts, use an empty dependency array.\n\n```jsx\nuseEffect(() => {\n console.log(\"Component mounted\");\n}, []);\n```\n\nThis is equivalent to the componentDidMount lifecycle behavior.\n\n---\n\n## Dependency Array Explained\n\nThe dependency array controls **when** the effect runs.\n\n```jsx\nuseEffect(() => {\n console.log(\"Count changed\");\n}, [count]);\n```\n\nRules:\n\n- No dependency array => runs after every render \n- Empty array => runs once \n- With dependencies => runs when dependencies change \n\n---\n\n## Fetching Data with useEffect\n\nA common use case is fetching data from an API.\n\n```jsx\nfunction Users() {\n const [users, setUsers] = useState([]);\n\n useEffect(() => {\n fetch(\"https://example.com/users\")\n .then(res => res.json())\n .then(data => setUsers(data));\n }, []);\n\n return <ul></ul>;\n}\n```\n\nAlways fetch data **inside useEffect**.\n\n---\n\n## Cleanup Functions\n\nEffects can return a cleanup function.\n\n```jsx\nuseEffect(() => {\n const timer = setInterval(() => {\n console.log(\"Running\");\n }, 1000);\n\n return () => {\n clearInterval(timer);\n };\n}, []);\n```\n\nCleanup runs:\n\n- Before the component unmounts \n- Before the effect re-runs \n\nThis prevents memory leaks.\n\n---\n\n## Basic Lifecycle Mapping\n\nIn functional components, lifecycle behavior maps like this:\n\n- Mount => useEffect with empty dependency \n- Update => useEffect with dependencies \n- Unmount => cleanup function \n\nReact Hooks replace traditional class lifecycle methods.\n\n---\n\n## Common useEffect Mistakes\n\nAvoid these mistakes:\n\n- Forgetting dependency array \n- Putting state updates incorrectly \n- Creating infinite loops \n- Fetching data outside useEffect \n\nAlways think about **when** the effect should run.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What side effects are \n- How useEffect works \n- Dependency array behavior \n- Fetching data with useEffect \n- Cleanup functions \n- Basic lifecycle concepts in React \n\nIn the next lesson, we will **build a small React project** to combine everything you have learned so far.\n\n---\n"
364
+ },
365
+ {
366
+ "slug": "introduction-to-nextjs",
367
+ "title": "NEXT101 - Introduction to Next.js",
368
+ "lesson": "NEXT101",
369
+ "series": "nextjs",
370
+ "shortTitle": "Introduction to Next.js",
371
+ "description": "Learn what Next.js is, why it was created, and how it extends React by solving real-world problems like SEO, routing, and performance.",
372
+ "date": "2023-10-30",
373
+ "readingMinutes": 2,
374
+ "body": "Next.js is a powerful framework built on top of React that enables developers to build **production-ready web applications**. \nIn this lesson, you will learn **what Next.js is**, **why it exists**, and **when you should use it instead of plain React**.\n\n## What Is Next.js?\n\nNext.js is an **open-source React framework** developed by Vercel. \nIt provides a structured way to build applications with built-in solutions for common problems that React alone does not solve out of the box.\n\nNext.js is not a replacement for React — it **extends React** with additional capabilities.\n\n---\n\n## Why Was Next.js Created?\n\nReact focuses on building user interfaces, but it leaves many decisions to the developer, such as:\n\n- Routing \n- SEO optimization \n- Performance optimization \n- Server-side rendering \n- Code splitting \n\nAs applications grew larger, these concerns became harder to manage consistently. \nNext.js was created to **standardize best practices** and reduce boilerplate.\n\n---\n\n## React vs Next.js\n\nReact by itself is a **library**. \nNext.js is a **framework**.\n\nKey differences:\n\n- React handles UI only \n- Next.js handles UI + routing + rendering strategies \n- React apps are typically client-side rendered \n- Next.js supports multiple rendering strategies \n\nNext.js provides opinions and structure, which helps teams scale projects.\n\n---\n\n## Rendering Strategies Explained\n\nNext.js supports different rendering approaches:\n\n- Client-Side Rendering (CSR) \n- Server-Side Rendering (SSR) \n- Static Site Generation (SSG) \n- Incremental Static Regeneration (ISR)\n\nThis flexibility allows developers to choose the best strategy for each page.\n\n---\n\n## SEO Problem in Traditional React Apps\n\nIn traditional React apps:\n\n- Content is rendered on the client \n- Search engines may see empty HTML \n- SEO requires additional setup \n\nNext.js solves this by rendering pages **on the server or at build time**, making content immediately available to search engines.\n\n---\n\n## File-Based Routing\n\nNext.js introduces **file-based routing**.\n\nInstead of configuring routes manually, routes are created automatically based on the folder structure. \nThis reduces complexity and improves readability.\n\nExample concept:\n\n- pages/index.js = `/` \n- pages/blog.js = `/blog` \n\nWe will explore this in detail in the next lesson.\n\n---\n\n## Performance by Default\n\nNext.js optimizes performance automatically by:\n\n- Code splitting \n- Lazy loading \n- Optimized images \n- Smart caching \n\nThese optimizations require manual configuration in plain React apps.\n\n---\n\n## When Should You Use Next.js?\n\nNext.js is a great choice when:\n\n- SEO matters \n- Performance is critical \n- You are building a content-heavy site \n- You want a scalable architecture \n- You plan to deploy to production \n\nFor small experiments or simple widgets, plain React may still be enough.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What Next.js is \n- Why it was created \n- How it extends React \n- Key differences between React and Next.js \n- Rendering strategies \n- SEO and performance benefits \n\nIn the next lesson, we will **create a Next.js project** and explore its folder structure.\n\n---\n"
375
+ },
376
+ {
377
+ "slug": "creating-a-nextjs-project",
378
+ "title": "NEXT102 - Creating a Next.js Project",
379
+ "lesson": "NEXT102",
380
+ "series": "nextjs",
381
+ "shortTitle": "Creating a Next.js Project",
382
+ "description": "Learn how to create a new Next.js application using create-next-app, understand the project structure, and run your first Next.js app locally.",
383
+ "date": "2023-11-02",
384
+ "readingMinutes": 2,
385
+ "body": "Before diving deeper into Next.js concepts, you need a solid development setup. \nIn this lesson, you will create your **first Next.js project** and learn how the basic folder structure works.\n\n## Prerequisites\n\nTo work with Next.js, make sure you have:\n\n- Node.js (LTS version recommended)\n- npm or yarn\n- A code editor (VS Code recommended)\n- Basic knowledge of React\n\nNext.js runs on top of Node.js during development and build time.\n\n---\n\n## Creating a Next.js App\n\nThe recommended way to create a new Next.js project is using **create-next-app**.\n\nRun the following command in your terminal:\n\n```bash\nnpx create-next-app@latest my-next-app\n```\n\nDuring setup, you may be asked several questions:\n\n- Use TypeScript? (No for now)\n- Use ESLint? (Yes recommended)\n- Use Tailwind CSS? (Optional)\n- Use src/ directory? (Yes recommended)\n- Use App Router? (Yes)\n\nThese choices help set up a modern Next.js project.\n\n---\n\n## Navigating Into the Project\n\nAfter installation completes:\n\n```bash\ncd my-next-app\nnpm run dev\n```\n\nThis starts the development server.\n\nOpen your browser and visit:\n\nhttp://localhost:3000\n\nYou should see the default Next.js welcome page.\n\n---\n\n## Understanding the Project Structure\n\nA typical Next.js project includes:\n\n- app/ = routing and UI structure\n- public/ = static assets\n- styles/ = global styles (optional)\n- next.config.js = Next.js configuration\n- package.json = dependencies and scripts\n\nNext.js automatically detects routes based on the **app** directory structure.\n\n---\n\n## The app Directory\n\nThe **app** directory is the core of modern Next.js applications.\n\nImportant files include:\n\n- app/page.js = root page\n- app/layout.js = root layout\n- app/globals.css = global styles\n\nThis structure replaces the older pages router approach.\n\n---\n\n## Running the Development Server\n\nTo start the dev server:\n\n```bash\nnpm run dev\n```\n\nTo stop it:\n\n- Press **Ctrl + C** in the terminal\n\nThe browser automatically refreshes when files change.\n\n---\n\n## Production Build Basics\n\nTo create a production build:\n\n```bash\nnpm run build\nnpm start\n```\n\nThis simulates how your app will behave in production.\n\n---\n\n## Common Beginner Mistakes\n\nAvoid these mistakes:\n\n- Editing files outside the app directory\n- Forgetting to restart the server after config changes\n- Mixing pages router with app router unintentionally\n\nSticking to one routing strategy keeps your project clean.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- How to create a Next.js project\n- How to run the development server\n- Basic Next.js project structure\n- The purpose of the app directory\n- How to build the app for production\n\nIn the next lesson, we will explore **file-based routing** and learn how Next.js handles navigation automatically.\n\n---\n"
386
+ },
387
+ {
388
+ "slug": "nextjs-file-based-routing",
389
+ "title": "NEXT103 - File-Based Routing in Next.js",
390
+ "lesson": "NEXT103",
391
+ "series": "nextjs",
392
+ "shortTitle": "File-Based Routing in Next.js",
393
+ "description": "Learn how Next.js creates routes automatically using the file system, including nested routes, dynamic segments, and basic navigation concepts.",
394
+ "date": "2023-11-05",
395
+ "readingMinutes": 2,
396
+ "body": "One of the most powerful features of Next.js is **file-based routing**. \nInstead of manually configuring routes, Next.js generates routes automatically based on your folder and file structure.\n\n## What Is File-Based Routing?\n\nFile-based routing means that **each folder and file inside the app directory becomes a route**. \nThis approach removes the need for a separate routing configuration and makes navigation predictable and scalable.\n\n---\n\n## The app Directory Recap\n\nIn modern Next.js, routing is handled inside the **app** directory.\n\nKey files:\n\n- app/page.js = root route (`/`) \n- app/layout.js = root layout \n- app/globals.css = global styles \n\nRoutes are created based on the folder structure under **app**.\n\n---\n\n## Creating Basic Routes\n\nEach folder containing a **page.js** file becomes a route.\n\nExample structure:\n\n```text\napp/\n page.js\n about/\n page.js\n blog/\n page.js\n```\n\nGenerated routes:\n\n- `/` \n- `/about` \n- `/blog` \n\nNo additional configuration is required.\n\n---\n\n## Nested Routes\n\nFolders can be nested to create nested routes.\n\n```text\napp/\n blog/\n page.js\n posts/\n page.js\n```\n\nGenerated routes:\n\n- `/blog` \n- `/blog/posts` \n\nNested routing mirrors the folder hierarchy.\n\n---\n\n## Dynamic Routes\n\nDynamic routes allow you to create pages with dynamic segments using square brackets.\n\nExample:\n\n```text\napp/\n blog/\n [slug]/\n page.js\n```\n\nThis generates routes like:\n\n- `/blog/hello-world` \n- `/blog/nextjs-routing` \n\nThe **slug** value can be accessed inside the page component.\n\n---\n\n## Accessing Route Parameters\n\nDynamic parameters are available via the **params** object.\n\n```jsx\nfunction BlogPost({ params }) {\n return <h1>{params.slug}</h1>;\n}\n\nexport default BlogPost;\n```\n\nThis allows you to render content based on the URL.\n\n---\n\n## Catch-All Routes\n\nCatch-all routes handle multiple dynamic segments.\n\nExample:\n\n```text\napp/docs/[...slug]/page.js\n```\n\nThis matches:\n\n- `/docs/a` \n- `/docs/a/b` \n- `/docs/a/b/c` \n\nThe slug parameter becomes an array of values.\n\n---\n\n## Optional Catch-All Routes\n\nOptional catch-all routes also match the parent path.\n\nExample:\n\n```text\napp/docs/[[...slug]]/page.js\n```\n\nThis matches:\n\n- `/docs` \n- `/docs/a` \n- `/docs/a/b` \n\nUseful for flexible documentation structures.\n\n---\n\n## Not Found Pages\n\nYou can define a custom 404 page using **not-found.js**.\n\n```text\napp/not-found.js\n```\n\nThis file is rendered when a route does not exist.\n\n---\n\n## Route Groups (Optional)\n\nRoute groups allow you to organize routes without affecting the URL.\n\nExample:\n\n```text\napp/(marketing)/page.js\napp/(dashboard)/page.js\n```\n\nBoth generate `/` but help structure the codebase.\n\n---\n\n## Common Routing Mistakes\n\nAvoid these issues:\n\n- Forgetting page.js inside folders \n- Mixing pages router and app router \n- Incorrect dynamic segment naming \n- Assuming folders without page.js create routes \n\nUnderstanding routing rules prevents navigation bugs.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What file-based routing is \n- How routes are generated automatically \n- Creating nested routes \n- Using dynamic and catch-all routes \n- Accessing route parameters \n- Organizing routes effectively \n\nIn the next lesson, we will compare **Pages Router vs App Router** and clarify when to use each approach.\n\n---\n"
397
+ },
398
+ {
399
+ "slug": "nextjs-pages-vs-app-router",
400
+ "title": "NEXT104 - Pages Router vs App Router",
401
+ "lesson": "NEXT104",
402
+ "series": "nextjs",
403
+ "shortTitle": "Pages Router vs App Router",
404
+ "description": "Understand the differences between the Pages Router and the App Router in Next.js, learn when to use each approach, and avoid common routing confusion.",
405
+ "date": "2023-11-08",
406
+ "readingMinutes": 2,
407
+ "body": "Next.js currently supports **two routing systems**: the Pages Router and the App Router. \nThis often creates confusion for developers who are new to the framework. \nIn this lesson, you will learn **what each router is**, **how they differ**, and **which one you should use**.\n\n## Why Are There Two Routers?\n\nThe **Pages Router** is the original routing system in Next.js and has been used for many years. \nThe **App Router** was introduced later to support modern React features such as **Server Components** and **layouts**.\n\nNext.js maintains both systems for backward compatibility.\n\n---\n\n## Pages Router Overview\n\nThe Pages Router is based on the **pages** directory.\n\nKey characteristics:\n\n- Routes are defined in the pages/ folder \n- Each file becomes a route \n- Uses getStaticProps and getServerSideProps \n- Client Components by default \n\nExample structure:\n\n```text\npages/\n index.js\n blog.js\n blog/[slug].js\n```\n\nGenerated routes:\n\n- `/` \n- `/blog` \n- `/blog/slug` \n\nThe Pages Router is simple and well documented.\n\n---\n\n## App Router Overview\n\nThe App Router is based on the **app** directory and modern React patterns.\n\nKey characteristics:\n\n- Uses the app/ folder \n- Supports layouts and nested layouts \n- Uses Server Components by default \n- Built-in data fetching with fetch \n\nExample structure:\n\n```text\napp/\n page.js\n blog/\n page.js\n [slug]/\n page.js\n```\n\nThe App Router enables more advanced patterns and better performance.\n\n---\n\n## Key Differences\n\nMain differences between the two routers:\n\n- Pages Router uses pages/ \n- App Router uses app/ \n- Pages Router relies on data fetching functions \n- App Router uses async components and fetch \n- App Router supports layouts natively \n- App Router is the future direction of Next.js \n\nBoth routers can coexist, but **should not be mixed for the same routes**.\n\n---\n\n## Data Fetching Comparison\n\n### Pages Router\n\nUses special functions:\n\n- getStaticProps \n- getServerSideProps \n\n### App Router\n\nUses the native fetch API:\n\n```js\nconst data = await fetch(\"https://example.com/api\");\n```\n\nData fetching is colocated with the component that needs it.\n\n---\n\n## Layout Support\n\n### Pages Router\n\nLayouts must be implemented manually using wrapper components.\n\n### App Router\n\nLayouts are built in using **layout.js** files.\n\n```text\napp/\n layout.js\n page.js\n```\n\nLayouts persist between navigations and improve performance.\n\n---\n\n## Server Components (Conceptual)\n\nThe App Router uses **React Server Components** by default.\n\nBenefits:\n\n- Smaller JavaScript bundles \n- Better performance \n- Direct access to backend resources \n\nClient-side interactivity is enabled explicitly when needed.\n\n---\n\n## Which Router Should You Use?\n\nFor new projects:\n\n- Use **App Router** \n\nFor existing projects:\n\n- Keep using **Pages Router** unless migrating \n\nFor this series:\n\n- We use **App Router** exclusively \n\nThis ensures modern best practices and future compatibility.\n\n---\n\n## Common Beginner Mistakes\n\nAvoid these mistakes:\n\n- Mixing pages/ and app/ for the same routes \n- Expecting getStaticProps to work in app router \n- Forgetting that components are server-side by default \n- Overusing client components \n\nUnderstanding the router choice early prevents major refactors later.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- Why Next.js has two routing systems \n- How the Pages Router works \n- How the App Router works \n- Key differences between them \n- Which router to choose and why \n\nIn the next lesson, we will explore **layouts and shared UI** using the App Router.\n\n---\n"
408
+ },
409
+ {
410
+ "slug": "nextjs-layouts-and-shared-ui",
411
+ "title": "NEXT105 - Layouts & Shared UI",
412
+ "lesson": "NEXT105",
413
+ "series": "nextjs",
414
+ "shortTitle": "Layouts & Shared UI",
415
+ "description": "Learn how to create shared layouts in Next.js using layout.js, build persistent UI like headers and footers, and structure applications with nested layouts.",
416
+ "date": "2023-11-11",
417
+ "readingMinutes": 2,
418
+ "body": "Layouts are one of the most powerful features of the **App Router** in Next.js. \nThey allow you to define **shared UI** that persists across route changes while keeping your code clean and scalable.\n\n## What Is a Layout?\n\nA layout is a component that **wraps one or more pages** and remains persistent during navigation. \nUnlike pages, layouts do not re-render when navigating between routes that share the same layout.\n\nCommon examples:\n\n- Header \n- Footer \n- Sidebar \n- Navigation menu \n\nLayouts help avoid repeating the same UI code on every page.\n\n---\n\n## Root Layout\n\nEvery Next.js app using the App Router must have a **root layout**.\n\nFile location:\n\n```text\napp/layout.js\n```\n\nExample root layout:\n\n```jsx\nexport default function RootLayout({ children }) {\n return (\n <html lang=\"en\">\n <body>\n <header>Header</header>\n <main>{children}</main>\n <footer>Footer</footer>\n </body>\n </html>\n );\n}\n```\n\nThe **children** prop represents the active page content.\n\n---\n\n## Shared UI with Layouts\n\nAny UI placed inside a layout will persist between page navigations.\n\nBenefits:\n\n- Faster navigation \n- Better user experience \n- Less unnecessary re-rendering \n- Cleaner code \n\nThis is ideal for elements like navigation bars or dashboards.\n\n---\n\n## Nested Layouts\n\nNext.js supports **nested layouts** for different sections of your app.\n\nExample structure:\n\n```text\napp/\n layout.js\n dashboard/\n layout.js\n page.js\n blog/\n layout.js\n page.js\n```\n\nEach section can have its own layout while still inheriting the root layout.\n\n---\n\n## How Nested Layouts Work\n\nLayouts wrap each other based on folder structure.\n\nOrder:\n\n1. Root layout \n2. Section layout \n3. Page \n\nThis allows fine-grained control over UI composition.\n\n---\n\n## Layout vs Page\n\nKey differences:\n\n- layout.js is persistent \n- page.js re-renders on navigation \n- layouts do not receive route params directly \n- layouts define structure, pages define content \n\nUnderstanding this distinction is crucial for proper architecture.\n\n---\n\n## Using Components Inside Layouts\n\nLayouts can import and use components like any other React file.\n\n```jsx\nimport Navbar from \"./components/Navbar\";\n\nexport default function RootLayout({ children }) {\n return (\n <html>\n <body>\n <Navbar />\n {children}\n </body>\n </html>\n );\n}\n```\n\nThis keeps layouts clean and reusable.\n\n---\n\n## Common Layout Mistakes\n\nAvoid these mistakes:\n\n- Putting page-specific logic in layouts \n- Overusing deeply nested layouts \n- Forgetting the children prop \n- Mixing layout and page responsibilities \n\nLayouts should focus on **structure**, not business logic.\n\n---\n\n## Best Practices\n\nRecommended practices:\n\n- Keep layouts simple \n- Use layouts for shared UI only \n- Prefer composition over duplication \n- Use nested layouts sparingly \n\nGood layout design improves long-term maintainability.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What layouts are in Next.js \n- How the root layout works \n- How to build shared UI \n- Using nested layouts \n- Differences between layouts and pages \n- Common mistakes and best practices \n\nIn the next lesson, we will explore **data fetching basics** and learn how Next.js handles server-side data loading.\n\n---\n"
419
+ },
420
+ {
421
+ "slug": "nextjs-data-fetching-basics",
422
+ "title": "NEXT106 - Data Fetching Basics",
423
+ "lesson": "NEXT106",
424
+ "series": "nextjs",
425
+ "shortTitle": "Data Fetching Basics",
426
+ "description": "Learn how data fetching works in Next.js App Router, understand server-side data loading, caching behavior, and basic rendering strategies using the fetch API.",
427
+ "date": "2023-11-14",
428
+ "readingMinutes": 3,
429
+ "body": "Data fetching is one of the areas where Next.js truly shines compared to plain React. \nIn this lesson, you will learn **how data fetching works in the App Router** and how to load data efficiently on the server.\n\n## Data Fetching in Next.js vs React\n\nIn a traditional React app:\n\n- Data is fetched on the client \n- UI renders first, then data loads \n- SEO and performance may suffer \n\nIn Next.js:\n\n- Data can be fetched on the server \n- HTML is generated with data included \n- Better SEO and faster first paint \n\nThis is a major architectural difference.\n\n---\n\n## Server Components by Default\n\nIn the App Router, components are **Server Components by default**.\n\nThis means:\n\n- Code runs on the server \n- You can fetch data directly \n- Sensitive logic stays server-side \n- Smaller JavaScript bundles \n\nClient-side interactivity is added only when needed.\n\n---\n\n## Basic Data Fetching with fetch\n\nNext.js uses the native **fetch API** for data fetching.\n\nExample:\n\n```jsx\nasync function Page() {\n const response = await fetch(\"https://example.com/api/posts\");\n const data = await response.json();\n\n return (\n <ul>\n {data.map(item => (\n <li key={item.id}>{item.title}</li>\n ))}\n </ul>\n );\n}\n\nexport default Page;\n```\n\nData is fetched **before rendering** the page.\n\n---\n\n## Async Components\n\nPages in the App Router can be **async functions**.\n\nBenefits:\n\n- Cleaner code \n- No extra hooks needed \n- Data and UI live together \n\nThis pattern replaces useEffect-based fetching in many cases.\n\n---\n\n## Caching Behavior\n\nNext.js automatically caches fetch requests by default.\n\nDefault behavior:\n\n- Requests are cached \n- Results are reused \n- Improves performance \n\nYou can control caching behavior explicitly.\n\n---\n\n## Disabling Cache (Dynamic Data)\n\nFor dynamic or frequently changing data, disable caching.\n\n```js\nfetch(\"https://example.com/api/posts\", {\n cache: \"no-store\"\n});\n```\n\nThis ensures fresh data on every request.\n\n---\n\n## Revalidation (Static Data with Updates)\n\nYou can revalidate cached data at intervals.\n\n```js\nfetch(\"https://example.com/api/posts\", {\n next: { revalidate: 60 }\n});\n```\n\nThis updates the data every 60 seconds while keeping performance benefits.\n\n---\n\n## Error Handling\n\nAlways handle failed requests.\n\n```js\nconst res = await fetch(\"https://example.com/api\");\n\nif (!res.ok) {\n throw new Error(\"Failed to fetch data\");\n}\n```\n\nErrors can be handled using error boundaries in Next.js.\n\n---\n\n## Client-Side Fetching (When Needed)\n\nSome data must be fetched on the client, such as:\n\n- User interactions \n- Auth-dependent data \n- Browser-only APIs \n\nIn such cases, mark the component as a client component.\n\n```jsx\n\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\nfunction ClientData() {\n const [data, setData] = useState(null);\n\n useEffect(() => {\n fetch(\"/api/data\")\n .then(res => res.json())\n .then(setData);\n }, []);\n\n return <div>{JSON.stringify(data)}</div>;\n}\n```\n\nUse client fetching only when necessary.\n\n---\n\n## Common Data Fetching Mistakes\n\nAvoid these mistakes:\n\n- Using useEffect for server data unnecessarily \n- Fetching data in multiple places \n- Ignoring caching behavior \n- Exposing secrets to the client \n\nUnderstanding where data should be fetched is critical.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- How data fetching differs in Next.js \n- Server Components and async pages \n- Basic fetch usage \n- Caching and revalidation \n- Client-side fetching scenarios \n- Common pitfalls \n\nIn the next lesson, we will explore **SEO in Next.js** and learn how to optimize pages for search engines.\n\n---\n"
430
+ },
431
+ {
432
+ "slug": "seo-in-nextjs",
433
+ "title": "NEXT107 - SEO in Next.js",
434
+ "lesson": "NEXT107",
435
+ "series": "nextjs",
436
+ "shortTitle": "SEO in Next.js",
437
+ "description": "Learn how to optimize your Next.js applications for search engines using the Metadata API, dynamic meta tags, and SEO best practices for modern web apps.",
438
+ "date": "2023-11-17",
439
+ "readingMinutes": 2,
440
+ "body": "Search Engine Optimization (SEO) is one of the main reasons developers choose Next.js over traditional React applications. \nIn this lesson, you will learn **how SEO works in Next.js** and how to properly optimize your pages for search engines.\n\n## Why SEO Matters\n\nSEO determines how easily users can find your website through search engines.\n\nGood SEO provides:\n\n- Better search visibility \n- Higher organic traffic \n- Faster indexing \n- Improved user trust \n\nNext.js makes SEO easier by rendering content on the server or at build time.\n\n---\n\n## SEO Problems in Client-Side React\n\nIn client-side rendered React apps:\n\n- HTML is mostly empty \n- Content loads after JavaScript execution \n- Search engines may not index content properly \n\nNext.js solves this by delivering **fully rendered HTML** to the browser and crawlers.\n\n---\n\n## Metadata API Overview\n\nNext.js provides a built-in **Metadata API** for managing SEO tags.\n\nMetadata includes:\n\n- title \n- description \n- keywords \n- Open Graph tags \n- Twitter cards \n\nThis API replaces manual `<head>` management.\n\n---\n\n## Static Metadata\n\nYou can define static metadata in a page or layout.\n\n```js\nexport const metadata = {\n title: \"My Page Title\",\n description: \"Page description for SEO\"\n};\n```\n\nThis metadata is automatically injected into the document head.\n\n---\n\n## Dynamic Metadata\n\nMetadata can be generated dynamically based on route parameters or fetched data.\n\n```js\nexport async function generateMetadata({ params }) {\n return {\n title: `Post - ${params.slug}`,\n description: \"Dynamic post description\"\n };\n}\n```\n\nThis is ideal for blog posts and dynamic pages.\n\n---\n\n## Layout-Level Metadata\n\nMetadata defined in **layout.js** applies to all nested pages.\n\n```js\nexport const metadata = {\n title: {\n default: \"My Website\",\n template: \"%s | My Website\"\n }\n};\n```\n\nThis ensures consistent branding across the site.\n\n---\n\n## Open Graph and Social Sharing\n\nNext.js supports Open Graph metadata for social sharing.\n\n```js\nexport const metadata = {\n openGraph: {\n title: \"My Page\",\n description: \"Social preview description\",\n images: [\"/og-image.png\"]\n }\n};\n```\n\nThis improves how links appear on social media platforms.\n\n---\n\n## SEO Best Practices in Next.js\n\nFollow these best practices:\n\n- Use meaningful page titles \n- Write unique meta descriptions \n- Use semantic HTML \n- Optimize images \n- Avoid duplicate content \n- Keep URLs clean and readable \n\nNext.js provides the foundation, but content quality still matters.\n\n---\n\n## SEO and Routing\n\nFile-based routing naturally creates **clean URLs**.\n\nExamples:\n\n- `/blog/my-first-post` \n- `/products/laptop` \n\nReadable URLs improve both SEO and user experience.\n\n---\n\n## Common SEO Mistakes\n\nAvoid these mistakes:\n\n- Missing meta descriptions \n- Reusing the same title everywhere \n- Blocking crawlers unintentionally \n- Relying only on client-side rendering \n\nSEO should be considered from the start of a project.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- Why SEO is important \n- How Next.js improves SEO \n- Using the Metadata API \n- Static and dynamic metadata \n- Layout-level metadata \n- Open Graph support \n- SEO best practices \n\nIn the next lesson, we will explore **images and performance optimization** using built-in Next.js features.\n\n---\n"
441
+ },
442
+ {
443
+ "slug": "nextjs-images-and-performance",
444
+ "title": "NEXT108 - Images Optimization",
445
+ "lesson": "NEXT108",
446
+ "series": "nextjs",
447
+ "shortTitle": "Images Optimization",
448
+ "description": "Learn how to optimize images and improve performance in Next.js using the next/image component, automatic optimizations, and best practices for faster web applications.",
449
+ "date": "2023-11-20",
450
+ "readingMinutes": 2,
451
+ "body": "Performance is a critical factor in modern web applications. \nIn this lesson, you will learn how Next.js optimizes images by default and how to use built-in tools to deliver fast and efficient user experiences.\n\n## Why Image Optimization Matters\n\nImages often represent the **largest portion of page weight**.\n\nPoor image handling can cause:\n\n- Slow page loads \n- High bounce rates \n- Bad Core Web Vitals scores \n- Poor SEO performance \n\nNext.js provides automatic image optimization to solve these issues.\n\n---\n\n## The next/image Component\n\nNext.js includes the **Image** component for optimized images.\n\nKey benefits:\n\n- Automatic resizing \n- Lazy loading by default \n- Modern image formats \n- Responsive behavior \n\nUsing next/image is recommended over standard `<img>` tags.\n\n---\n\n## Basic Image Usage\n\nExample usage of the Image component:\n\n```jsx\nimport Image from \"next/image\";\n\nexport default function Page() {\n return (\n <Image\n src=\"/hero.png\"\n alt=\"Hero image\"\n width={600}\n height={400}\n />\n );\n}\n```\n\nWidth and height are required to prevent layout shifts.\n\n---\n\n## Static Images\n\nImages inside the **public** folder can be referenced directly.\n\nExample:\n\n- public/logo.png \n\nUsage:\n\n```jsx\n<Image src=\"/logo.png\" alt=\"Logo\" width={120} height={60} />\n```\n\nStatic assets are served efficiently by Next.js.\n\n---\n\n## Remote Images\n\nYou can also optimize images hosted on external domains.\n\nFirst, configure allowed domains:\n\n```js\nmodule.exports = {\n images: {\n domains: [\"images.example.com\"]\n }\n};\n```\n\nThen use the Image component normally.\n\n---\n\n## Lazy Loading Explained\n\nBy default, next/image uses **lazy loading**.\n\nThis means:\n\n- Images load only when visible \n- Faster initial page load \n- Reduced bandwidth usage \n\nLazy loading improves performance automatically without extra setup.\n\n---\n\n## Priority Images\n\nFor important images (like hero banners), you can prioritize loading.\n\n```jsx\n<Image\n src=\"/hero.png\"\n alt=\"Hero\"\n width={800}\n height={500}\n priority\n/>\n```\n\nUse this sparingly to avoid blocking rendering.\n\n---\n\n## Image Sizes and Responsiveness\n\nUse the sizes prop for responsive images.\n\n```jsx\n<Image\n src=\"/banner.png\"\n alt=\"Banner\"\n fill\n sizes=\"(max-width: 768px) 100vw, 50vw\"\n/>\n```\n\nThis allows the browser to choose the best image size.\n\n---\n\n## Other Performance Optimizations\n\nNext.js improves performance through:\n\n- Automatic code splitting \n- Server Components \n- Built-in caching \n- Static generation \n\nThese features reduce JavaScript size and improve load times.\n\n---\n\n## Common Image Mistakes\n\nAvoid these mistakes:\n\n- Using `<img>` instead of next/image \n- Missing width and height \n- Overusing priority images \n- Serving oversized images \n\nCorrect image usage directly impacts performance scores.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- Why image optimization is important \n- How next/image works \n- Using static and remote images \n- Lazy loading and priority images \n- Responsive image techniques \n- Performance best practices \n\nIn the next lesson, we will explore **styling in Next.js** and learn how to manage styles effectively in Next.js applications.\n\n---\n"
452
+ },
453
+ {
454
+ "slug": "styling-in-nextjs",
455
+ "title": "NEXT109 - Styling in Next.js",
456
+ "lesson": "NEXT109",
457
+ "series": "nextjs",
458
+ "shortTitle": "Styling in Next.js",
459
+ "description": "Learn how to style Next.js applications using global CSS, CSS Modules, component-scoped styles, and best practices for maintainable UI development.",
460
+ "date": "2023-11-23",
461
+ "readingMinutes": 2,
462
+ "body": "Styling in Next.js builds upon standard CSS concepts while adding **framework-specific conventions** for scalability and performance. \nIn this lesson, you will learn the recommended ways to style Next.js applications and understand when to use each approach.\n\n## Styling Options in Next.js\n\nNext.js supports multiple styling strategies out of the box:\n\n- Global CSS \n- CSS Modules \n- Component-scoped styles \n- Inline styles (limited use) \n\nChoosing the right strategy helps keep your UI consistent and maintainable.\n\n---\n\n## Global CSS\n\nGlobal CSS applies styles across the entire application.\n\nGlobal styles must be imported in the **root layout**.\n\nExample file:\n\n- app/globals.css \n\nImporting global styles:\n\n```jsx\nimport \"./globals.css\";\n```\n\nGlobal CSS is best for:\n\n- Resets \n- Typography \n- Base styles \n- Design tokens \n\n---\n\n## CSS Modules\n\nCSS Modules scope styles **locally to a component**.\n\nFile naming convention:\n\n- Component.module.css \n\nExample CSS module:\n\n```css\n.title {\n font-size: 24px;\n color: blue;\n}\n```\n\nUsing CSS Modules:\n\n```jsx\nimport styles from \"./Title.module.css\";\n\nfunction Title() {\n return <h1 className={styles.title}>Hello Next.js</h1>;\n}\n```\n\nCSS Modules prevent class name collisions automatically.\n\n---\n\n## Component-Scoped Styling\n\nComponent-scoped styles are achieved using CSS Modules or colocated styles.\n\nBenefits:\n\n- Predictable styling \n- Easy refactoring \n- No global conflicts \n\nThis approach scales well in large applications.\n\n---\n\n## Conditional Styling\n\nStyles can change based on props or state.\n\n```jsx\nfunction Button({ active }) {\n return (\n <button\n className={active ? \"btn active\" : \"btn\"}\n >\n Click\n </button>\n );\n}\n```\n\nThis pattern is common for interactive UI elements.\n\n---\n\n## Inline Styles\n\nInline styles use JavaScript objects.\n\n```jsx\nfunction Box() {\n return (\n <div style={{ padding: \"16px\", backgroundColor: \"lightgray\" }}>\n Box\n </div>\n );\n}\n```\n\nInline styles should be used sparingly because they:\n\n- Do not support pseudo-classes \n- Are harder to maintain \n- Bypass CSS optimizations \n\n---\n\n## Styling Layouts vs Pages\n\nBest practice:\n\n- Layout styles = structure and shared UI \n- Page styles = page-specific content \n\nThis separation keeps responsibilities clear.\n\n---\n\n## Styling Best Practices\n\nFollow these guidelines:\n\n- Prefer CSS Modules for components \n- Use global CSS only when necessary \n- Keep styles close to components \n- Avoid overly complex selectors \n- Be consistent across the project \n\nGood styling practices improve long-term maintainability.\n\n---\n\n## Common Styling Mistakes\n\nAvoid these mistakes:\n\n- Putting everything in global CSS \n- Mixing multiple styling strategies randomly \n- Overusing inline styles \n- Ignoring responsive design \n\nConsistency matters more than the chosen method.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- Styling options available in Next.js \n- How to use global CSS \n- How CSS Modules work \n- Component-scoped styling patterns \n- Conditional and inline styling \n- Best practices and common pitfalls \n\nIn the next lesson, we will explore **environment variables in Next.js** and learn how to manage configuration securely.\n\n---\n"
463
+ },
464
+ {
465
+ "slug": "nextjs-environment-variables",
466
+ "title": "NEXT110 - Environment Variables",
467
+ "lesson": "NEXT110",
468
+ "series": "nextjs",
469
+ "shortTitle": "Environment Variables",
470
+ "description": "Learn how to use environment variables in Next.js, understand public vs private variables, and manage configuration securely for development and production environments.",
471
+ "date": "2023-11-26",
472
+ "readingMinutes": 2,
473
+ "body": "Environment variables are essential for managing **configuration and secrets** in real-world applications. \nIn this lesson, you will learn how Next.js handles environment variables and how to use them safely.\n\n## What Are Environment Variables?\n\nEnvironment variables are key-value pairs used to store configuration outside of the source code.\n\nCommon use cases:\n\n- API keys\n- Database URLs\n- Feature flags\n- Environment-specific settings\n\nThey help keep sensitive data out of version control.\n\n---\n\n## Environment Files in Next.js\n\nNext.js supports multiple environment files:\n\n- .env.local\n- .env.development\n- .env.production\n\nThe most common file is **.env.local**.\n\nExample:\n\n```env\nAPI_URL=https://api.example.com\nSECRET_KEY=supersecret\n```\n\nThe .env.local file should **never** be committed to Git.\n\n---\n\n## Accessing Environment Variables\n\nEnvironment variables are accessed using **process.env**.\n\n```js\nconst apiUrl = process.env.API_URL;\n```\n\nVariables are replaced at build time.\n\n---\n\n## Public vs Private Variables\n\nNext.js distinguishes between public and private variables.\n\n### Private Variables\n\n- Available only on the server\n- Used for secrets\n\nExample:\n\n```env\nDATABASE_URL=mysql://user:pass@localhost:3306/db\n```\n\n### Public Variables\n\n- Exposed to the browser\n- Must start with **NEXT*PUBLIC***\n\nExample:\n\n```env\nNEXT_PUBLIC_SITE_NAME=MyWebsite\n```\n\n```js\nconst siteName = process.env.NEXT_PUBLIC_SITE_NAME;\n```\n\nNever expose secrets using public variables.\n\n---\n\n## Using Variables in Server Components\n\nServer Components can safely access private variables.\n\n```js\nconst dbUrl = process.env.DATABASE_URL;\n```\n\nThis code never runs in the browser.\n\n---\n\n## Using Variables in Client Components\n\nClient Components can only access **NEXT*PUBLIC*** variables.\n\n```jsx\n\"use client\";\n\nconst siteName = process.env.NEXT_PUBLIC_SITE_NAME;\n```\n\nAttempting to access private variables in client components will fail.\n\n---\n\n## Environment Variables in Production\n\nIn production environments:\n\n- Variables are set via hosting platform\n- .env files are usually not deployed\n- Secrets are managed through dashboards\n\nPlatforms like Vercel provide UI for managing environment variables.\n\n---\n\n## Common Mistakes\n\nAvoid these mistakes:\n\n- Committing .env.local to Git\n- Exposing secrets with NEXT*PUBLIC*\n- Forgetting to restart the dev server\n- Assuming variables update automatically\n\nEnvironment changes require a server restart.\n\n---\n\n## Best Practices\n\nRecommended practices:\n\n- Use .env.local for local development\n- Prefix public variables correctly\n- Keep secrets server-only\n- Document required environment variables\n\nGood configuration management improves security and stability.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What environment variables are\n- How Next.js handles env files\n- Public vs private variables\n- Using variables in server and client components\n- Production environment management\n- Common mistakes and best practices\n\nIn the next lesson, we will explore **API Routes in Next.js** and learn how to build backend logic inside a Next.js application.\n\n---\n"
474
+ },
475
+ {
476
+ "slug": "nextjs-api-routes",
477
+ "title": "NEXT111 - API Routes in Next.js",
478
+ "lesson": "NEXT111",
479
+ "series": "nextjs",
480
+ "shortTitle": "API Routes in Next.js",
481
+ "description": "Learn how to build backend endpoints using Next.js API Routes, handle HTTP methods, return JSON responses, and connect frontend and backend logic in a single project.",
482
+ "date": "2023-11-29",
483
+ "readingMinutes": 2,
484
+ "body": "Next.js allows you to build **backend functionality** directly inside your application using **API Routes**. \nIn this lesson, you will learn how API Routes work in the App Router and how to create simple backend endpoints without setting up a separate server.\n\n## What Are API Routes?\n\nAPI Routes are server-side functions that handle HTTP requests and return responses, usually in JSON format.\n\nThey are commonly used for:\n\n- Fetching data \n- Handling form submissions \n- Authentication logic \n- Server-side validation \n- Acting as a backend for frontend components \n\nAPI Routes make Next.js a **fullstack framework**.\n\n---\n\n## API Routes in the App Router\n\nIn the App Router, API Routes are defined using **route.js** files.\n\nFile location pattern:\n\n```text\napp/api/route.js\n```\n\nEach route.js file represents an API endpoint.\n\n---\n\n## Creating a Basic API Route\n\nExample folder structure:\n\n```text\napp/api/hello/route.js\n```\n\nBasic GET handler:\n\n```js\nexport async function GET() {\n return new Response(\n JSON.stringify({ message: \"Hello from API\" }),\n {\n headers: { \"Content-Type\": \"application/json\" }\n }\n );\n}\n```\n\nThis endpoint is available at:\n\n- `/api/hello`\n\n---\n\n## Handling HTTP Methods\n\nAPI Routes can handle different HTTP methods.\n\nExample:\n\n```js\nexport async function POST(request) {\n const body = await request.json();\n\n return new Response(\n JSON.stringify({ received: body }),\n { status: 201 }\n );\n}\n```\n\nSupported methods include:\n\n- GET \n- POST \n- PUT \n- PATCH \n- DELETE \n\n---\n\n## Returning JSON Responses\n\nResponses should be returned using the **Response** object.\n\n```js\nreturn new Response(\n JSON.stringify({ success: true }),\n {\n status: 200,\n headers: { \"Content-Type\": \"application/json\" }\n }\n);\n```\n\nAlways set appropriate status codes and headers.\n\n---\n\n## Accessing Query Parameters\n\nQuery parameters can be accessed via the request URL.\n\n```js\nexport async function GET(request) {\n const { searchParams } = new URL(request.url);\n const name = searchParams.get(\"name\");\n\n return new Response(\n JSON.stringify({ name }),\n { status: 200 }\n );\n}\n```\n\nExample request:\n\n- `/api/hello?name=Emre`\n\n---\n\n## Dynamic API Routes\n\nDynamic segments work the same as page routing.\n\nExample structure:\n\n```text\napp/api/posts/[id]/route.js\n```\n\nAccessing params:\n\n```js\nexport async function GET(request, { params }) {\n return new Response(\n JSON.stringify({ id: params.id }),\n { status: 200 }\n );\n}\n```\n\nThis allows building REST-like APIs.\n\n---\n\n## Calling API Routes from the Frontend\n\nAPI Routes can be called using fetch.\n\n```js\nfetch(\"/api/hello\")\n .then(res => res.json())\n .then(data => console.log(data));\n```\n\nThis keeps frontend and backend tightly integrated.\n\n---\n\n## API Routes and Security\n\nImportant security considerations:\n\n- Validate incoming data \n- Never expose secrets \n- Use server-side checks \n- Protect sensitive endpoints \n\nAPI Routes run only on the server.\n\n---\n\n## Common API Route Mistakes\n\nAvoid these mistakes:\n\n- Writing heavy business logic without structure \n- Returning plain objects instead of Response \n- Forgetting HTTP status codes \n- Exposing private environment variables \n\nTreat API Routes like a real backend.\n\n---\n\n## Summary\n\nIn this lesson, you learned:\n\n- What API Routes are \n- How to create API endpoints \n- Handling HTTP methods \n- Returning JSON responses \n- Using query parameters \n- Dynamic API routes \n- Calling APIs from the frontend \n- Security best practices \n\nIn the next and final lesson, we will **build a small Next.js project** that combines routing, data fetching, SEO, styling, and API routes into a single application.\n\n---\n"
485
+ },
486
+ {
487
+ "slug": "ekurt-in-your-terminal",
488
+ "title": "ekurt.dev, Now in Your Terminal",
489
+ "lesson": null,
490
+ "series": "notes",
491
+ "shortTitle": "ekurt.dev, Now in Your Terminal",
492
+ "description": "The Terminal app on this site was always a small shell over real content. Now it runs in yours too — npx ekurt — and a real terminal turned out to be good at more than I expected.",
493
+ "date": "2026-12-01",
494
+ "readingMinutes": 4,
495
+ "body": "This site has a Terminal app. Open it and you get `ekurtsh`, a little shell over the site's real content: `ls` the projects, `cat about-me.md`, `play bugsweeper`. It was always the most \"me\" corner of the OS, so the obvious next step was to let it leave the browser.\n\n```bash\nnpx ekurt\n```\n\nThat's the whole install. With Node.js 22 or newer, it boots the way this site does — the e_ mark, a progress bar, skip it with any key — and leaves you at a prompt:\n\n```text\nvisitor@ekurt ~ % ls\nblog/\nprojects/\nabout-me.md\nbookmarks.txt\ncv.pdf\n```\n\nSame files, same commands, same colours. This post is about what changed on the way, and the parts that took longer than they should have.\n\n## One source of truth\n\nThe CLI doesn't have its own copy of anything I would have to keep up to date by hand. A sync script reads this site's repository — the posts, the projects, the about text, the bookmarks — and applies the same rules the site does: drafts stay out, a title like `REACT106 - …` puts a post in the React series, project covers are lifted out of the text. Run it, publish a new version, and both shells say the same thing.\n\nThe only hand-written pieces are the CV and an about text reworded for a terminal. \"Drag the windows around\" reads oddly when there are no windows.\n\n## What a real terminal adds\n\nIn the browser, `cat` on a blog post shows a summary and a link: the window next to it is a much better reader. In a terminal there is no window next to it, so the CLI does the job itself. `cat` renders whole posts and project pages from markdown: wrapped to the width of your terminal, with lists, tables and highlighted code. At the end of every lesson it tells you which file comes next, so you can work through a whole series without leaving the prompt.\n\nA few things only make sense there:\n\n- **`cv`** prints the résumé, and `npx ekurt --export md` writes it to a file.\n- **`search`** looks through projects, posts and bookmarks at once.\n- **Every command works on its own.** `npx ekurt cat about-me.md` prints the page and exits, and the output pipes cleanly into whatever you like.\n- **`contact`** is the Mail app as a prompt: name, email, a few lines of message, send. It goes through the same endpoint as the form on this site.\n\n## Games on the alternate screen\n\nBugsweeper and Memory from the Arcade play right in the terminal, with the arrow keys. The rules are the exact same module as on the site; only the drawing is new. Cells are three characters wide, because terminal cells are roughly twice as tall as they are wide, and three characters make a cell look square.\n\nThey run on the terminal's *alternate screen*, the same trick `vim` and `less` use. Quit a game and your scrollback is exactly as you left it. The tricky part is handing the keyboard over. The shell reads lines with Node's `readline`, and merely pausing it isn't enough: it would still see every keypress, and arrow keys meant for the game would end up in the prompt's history. So the shell steps aside completely. Its input closes while a game runs, and a fresh one with the same history takes over when it ends.\n\nThe first version also had the board drifting sideways whenever the status line below it changed length, because everything was centred on the widest line. Now it is centred on the board itself, and the text can do what it likes.\n\n## The small things\n\n- **Ctrl+C behaves like a shell.** It prints `^C`, drops the line, and gives you a fresh prompt. Inside the contact form it discards the message instead.\n- **Tab completes** commands, then files and options. `cd b` and Tab gives you `blog/`.\n- **Typos get a suggestion.** Type `about-me.md` on its own and the shell asks if you meant `cat about-me.md`.\n- **Links are clickable** in terminals that support it; everywhere else they stay plain text instead of turning into escape-code soup.\n- **`panic` still works.** You'll see.\n\n## Publishing it\n\nThis was my first package on npm, and the last step held a surprise. Publishing needs two-factor authentication now, and right after a successful publish, the registry showed a placeholder called `0.0.0-stage` instead of my package. It turns out npm processes a new package for a few minutes before it goes live. It was there five minutes later, and nothing had gone wrong; I just looked too early.\n\nIf you have a terminal open, give it a try:\n\n```bash\nnpx ekurt\n```\n\nAnd if you're reading this in the Terminal app here, type `install` — it will tell you the same thing.\n"
496
+ },
497
+ {
498
+ "slug": "building-ekurtos",
499
+ "title": "Building ekurtOS",
500
+ "lesson": null,
501
+ "series": "notes",
502
+ "shortTitle": "Building ekurtOS",
503
+ "description": "Why my personal site now boots like an operating system — and what it took to make windows, a phone home screen and an arcade feel right in the browser.",
504
+ "date": "2026-11-30",
505
+ "readingMinutes": 5,
506
+ "body": "My old site was a perfectly normal portfolio: a header, a list of posts, a list of projects. It did its job, and nobody remembered it.\n\nSo I rebuilt it as a small operating system. On a computer you get a desktop with a menu bar, a dock and windows you can drag around. On a tablet you get a home screen and Split View. On a phone you get widgets, a dock and apps that grow out of their icons. Same content everywhere — only the \"shell\" around it changes.\n\nThis post is about the decisions behind it, and the handful of problems that took far longer than they should have.\n\n## One site, three shells\n\nThe first rule was that **apps don't know where they live**. The Blog app only renders posts; whether it sits in a draggable window, fills a phone screen or shares a tablet with another app is the shell's business. That kept every app small and let me build the desktop first and the phone and tablet later without touching the apps again.\n\nThe device is chosen by **viewport and input**, not by user agent: width plus the `pointer` and `hover` media queries. Resize the window and the site switches from desktop to tablet to phone live. A phone turned sideways stays a phone — it just rearranges its widgets.\n\n## Every window has a URL\n\nAn OS that forgets where you were on refresh isn't much fun to share. Every app and document has a real address — `/blog/<post>`, `/projects/ninefold`, `/arcade/bugsweeper` — and opening a window updates the address bar with `history.pushState`. Back and forward work, links are shareable, and the old URLs from my previous site still resolve to the same content.\n\nMoving between apps is deliberately **not** a router navigation. The OS is one long-lived client component; swapping pages would throw its state away. Every known URL is still prerendered on the server, so a visitor landing on a deep link gets the right app open from the start.\n\n## Crawlers get a plain website\n\nA desktop made of JavaScript is invisible to search engines and useless without JS. So each URL is first rendered as plain, semantic HTML — headings, articles, lists of links — and only once the client knows the device does the OS boot on top of it. Search engines, link previews and screen readers before hydration all see a normal page. Metadata, a sitemap, structured data and an RSS feed are generated from the same content files.\n\nTo make the first paint fast, the post and project lists are inlined into the page as JSON. Apps read that seed as an already-resolved promise, so the first window opens without a loading spinner.\n\n## Making windows feel like windows\n\nThe window manager is a small Zustand store: open windows, their order, which one has focus. The details are where it gets interesting:\n\n- A click on a maximized window's title bar shouldn't restore it — only a real drag should. A 4px threshold fixed that.\n- Dragging a window to the left or right edge tiles it to half the screen; dragging it to the menu bar maximizes it. Pull it away and it returns to its old size.\n- The dock grows its icons on hover, but the bar itself keeps a fixed height, so nothing jumps.\n\nNone of this is visible in a screenshot. All of it is visible in the first ten seconds of using it.\n\n## The iPhone bug that ate a day\n\nInstalled to the home screen, the phone shell left a black strip at the bottom of the screen. The viewport height on my iPhone 13 kept flipping between 844 and 797 pixels — with or without the status bar — and anything sized to it ended up short.\n\nI tried `100dvh`, then `position: fixed; inset: 0`, then measuring the gap in JavaScript and stretching the shell. Each fix broke something else. The real fix was already in one of my other projects, where I had hit the same bug months earlier:\n\n```css\n@media (display-mode: standalone) {\n html, body { height: 100lvh; }\n}\n```\n\nThe shells then size themselves to 100% of that instead of being fixed to the viewport. One more trap: the rule has to come *after* the base `html, body { height: 100% }`, or it silently loses. Lesson learned: check your own notes before you start guessing.\n\n## Small things\n\n- **The wallpaper is code.** A generative canvas drawn at low resolution and scaled up; it pauses when the tab is hidden and stands still for anyone who prefers reduced motion.\n- **Share images are generated** for every page. Getting the text right took stripping kerning from the font, because the image renderer measured words without kerning but drew them with it — leaving odd gaps between words.\n- **It works offline.** A service worker keeps the shell and content; when a new version ships, a small \"Update available\" notice offers a restart instead of swapping code under your feet.\n- **Interface sounds** are synthesised with the Web Audio API — no audio files — and off by default.\n\n## An arcade, because every OS needs games\n\nThe newest app is the Arcade. Two mini games are made for ekurtOS — Bugsweeper, where you hunt bugs hidden in a grid, and Memory, matching the system's own app icons — and two of my own games run inside it from their live sites. Everything works with a mouse, a keyboard or a thumb: long-press to flag a cell, and the boards scale to fit any screen.\n\n## What's next\n\nMobile performance is the next thing on my list: the shells are rendered on the client, which costs time on slower phones. After that, more of my own projects will find their way into the Projects folder.\n\nIf you're reading this on a computer, try dragging this window to the edge of the screen. And if you'd like to say hi, Mail is in the dock — I read everything.\n"
507
+ }
508
+ ]