Laract News Portal
Simple news blog built with Laravel 11 and React using Inertia.js and Breeze for learning fullstack development
Share this project:
Project Overview
Laract News Portal
A simple news blog application built with Laravel 11 and React, demonstrating the powerful combination of Laravel backend with React frontend using Inertia.js. This learning project showcases modern fullstack development practices.
π Overview
This project was created as a learning exercise to understand how to integrate Laravel 11 with React using Inertia.js. Based on the excellent tutorial by Dea Afrizal, this implementation upgrades the stack to Laravel 11 while maintaining all the core functionality.
β¨ Features
-
News Management (CRUD)
- Create news articles with rich content
- Read news with clean, responsive layout
- Update existing articles
- Delete articles with confirmation
-
Modern Stack Integration
- Seamless SPA experience with Inertia.js
- React components for interactive UI
- Laravel Breeze for authentication
- Real-time reactivity without API endpoints
-
User Experience
- Responsive design with Tailwind CSS
- Fast page transitions
- No page reloads (SPA behavior)
- Clean, modern interface
π οΈ Tech Stack
| Technology | Version | Purpose |
|---|---|---|
| Laravel | 11.x | Backend framework |
| React | 19.x | Frontend library |
| Inertia.js | - | Glue between Laravel & React |
| Laravel Breeze | - | Authentication scaffolding |
| Tailwind CSS | - | Utility-first styling |
| Vite | - | Frontend tooling |
| MySQL | - | Database |
π Project Structure
learn-laract-news/
βββ app/
β βββ Http/Controllers/ # Laravel controllers
β βββ Models/ # Eloquent models
βββ database/
β βββ migrations/ # Database migrations
β βββ seeders/ # NewsSeeder.php
βββ resources/
β βββ js/
β β βββ Pages/ # React page components
β β βββ Components/ # Reusable React components
β β βββ app.jsx # React entry point
β βββ css/
β βββ app.css # Tailwind styles
βββ routes/
β βββ web.php # Inertia routes
βββ tailwind.config.js # Tailwind configuration
π Getting Started
Prerequisites
- PHP 8.2 or higher
- Composer
- Node.js & npm
- MySQL
Installation Steps
-
Clone the Repository
git clone <repository-url> cd learn-laract-news -
Install PHP Dependencies
composer install -
Install Node Dependencies
npm install -
Environment Setup
cp .env.example .env php artisan key:generate -
Configure Database
Create database named
laract-newsin MySQL, then update.env:DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laract-news DB_USERNAME=root DB_PASSWORD=your_password -
Run Migrations
php artisan migrate -
Seed Sample Data
php artisan db:seed --class=NewsSeeder -
Start Development Servers
Terminal 1 - Frontend:
npm run devTerminal 2 - Backend:
php artisan serve -
Access Application
Open browser:
http://localhost:8000
π» Usage
Viewing News
- Homepage displays all news articles
- Click on article to read full content
- Responsive grid layout
Managing News (Admin)
- Register/Login to access admin features
- Navigate to "Create News"
- Fill in article details:
- Title
- Content
- Author
- Category
- Featured image
- Submit to publish
Editing News
- Click "Edit" on any article (admin only)
- Modify content as needed
- Save changes
Deleting News
- Click "Delete" button
- Confirm deletion
- Article removed from database
π Learning Objectives
This project teaches:
Frontend (React + Inertia)
- React component composition
- Inertia.js page components
- Form handling with Inertia
- Client-side routing
- State management
Backend (Laravel)
- Laravel 11 features
- Inertia responses
- CRUD operations
- Database relationships
- File uploads
- Authentication with Breeze
Full Stack Integration
- Passing data from Laravel to React
- Form submissions without API
- Shared data across components
- Flash messages and notifications
π§ Configuration
Inertia Setup
The app is configured to use Inertia.js for seamless integration:
// Controller example
use Inertia\Inertia;
public function index()
{
return Inertia::render('News/Index', [
'news' => News::all()
]);
}
React Component Example
// resources/js/Pages/News/Index.jsx
import React from 'react';
import { Head, Link } from '@inertiajs/react';
export default function Index({ news }) {
return (
<>
<Head title="News" />
<div className="grid grid-cols-3 gap-4">
{news.map(article => (
<div key={article.id} className="p-4 border">
<h2>{article.title}</h2>
<p>{article.excerpt}</p>
<Link href={`/news/${article.id}`}>
Read More
</Link>
</div>
))}
</div>
</>
);
}
π‘ API vs Inertia
Unlike traditional SPAs, this project doesn't use a separate API:
- No API endpoints needed
- No Axios/Fetch calls
- Direct controller to component data flow
- Automatic CSRF protection
π¨ Styling
Tailwind CSS is configured and ready:
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<h1 className="text-3xl font-bold text-gray-900">
News Portal
</h1>
</div>
π Troubleshooting
Vite not running?
npm run dev
Inertia version mismatch?
composer update inertiajs/inertia-laravel
npm install @inertiajs/react@latest
CSS not loading?
npm run build
php artisan optimize:clear
π Acknowledgments
This project is based on the tutorial by Dea Afrizal:
- Original repo: laract9-crud-basic-portal-berita
- YouTube channel for tutorials
Big thanks to Dea Afrizal for the excellent learning resources! π
Differences from Original
- Upgraded to Laravel 11 (original used Laravel 9)
- Updated React to version 19
- Modern Vite configuration
- Latest Breeze implementation
- Enhanced Tailwind setup
πResources
- Laravel Documentation
- React Documentation
- Inertia.js Documentation
- Tailwind CSS Documentation
- Dea Afrizal's Tutorial
π€ Contributing
This is a learning project. Feel free to fork and experiment!
π License
Open source - available for educational purposes.
Happy Learning! πβ¨
Built while learning Laravel + React with Inertia.js