marekmiklusek / laravel-starter-kit-react
Laravel React starter kit with code quality tools pre-configured.
Package info
github.com/marekmiklusek/laravel-starter-kit-react
Language:TypeScript
Type:project
pkg:composer/marekmiklusek/laravel-starter-kit-react
Requires
- php: ^8.4
- inertiajs/inertia-laravel: ^3.0.6
- laravel/fortify: ^1.37.0
- laravel/framework: ^13.7
- laravel/tinker: ^3.0.2
- laravel/wayfinder: ^0.1.16
- nunomaduro/essentials: ^1.2.0
Requires (Dev)
- driftingly/rector-laravel: ^2.3.0
- fakerphp/faker: ^1.24.1
- larastan/larastan: ^3.9.6
- laravel/boost: ^2.4.6
- laravel/pail: ^1.2.6
- laravel/pao: ^1.0.6
- laravel/pint: ^1.29.1
- laravel/sail: ^1.58
- mockery/mockery: ^1.6.12
- nunomaduro/collision: ^8.9.4
- pestphp/pest: ^4.6.3
- pestphp/pest-plugin-browser: ^4.3.1
- pestphp/pest-plugin-laravel: ^4.1
- pestphp/pest-plugin-type-coverage: ^4.0.4
- rector/rector: ^2.4.2
README
Laravel's official React starter kit enhanced with development workflow tools, code quality standards, and additional developer experience improvements from laravel-starter-kit. โจ
Built with Inertia.js, React, Tailwind CSS, and Laravel Wayfinder.
๐ Requirements
- PHP >= 8.4.0
- Composer
- Node.js & NPM
- MySQL (or your preferred database)
๐ Quick Start
Note
- In
config/database.php,'engine' => 'InnoDB',is used as the default for bothmysqlandmariadbconnections. - In
config/essentials.php, models are unguarded by default viaUnguard::class => true. This allows mass assignment without explicitly defining$fillableproperties. You can change this setting if you prefer to use guarded models.
๐ฆ Installation
Create a new Laravel React project:
composer create-project marekmiklusek/laravel-starter-kit-react --prefer-dist app-name
Run the automated setup script:
composer setup
This command will:
- Install PHP dependencies via Composer
- Create
.envfile from.env.example(if not exists) - Generate application key
- Run database migrations
- Install NPM dependencies
- Build frontend assets
โ๏ธ Additional Setup
๐ง Environment Configuration
After running composer setup, configure your .env file with your database credentials:
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=your_database_name DB_USERNAME=your_username DB_PASSWORD=your_password
๐ Browser Testing Setup (Optional)
If you plan to use Pest's browser testing capabilities, install Playwright:
npm install playwright npx playwright install
This installs the necessary browser binaries for running browser tests.
๐ป Development
๐ฅ๏ธ Running the Development Server
Start all development services concurrently:
composer dev
This starts:
- Laravel development server (port 8000) - Your Inertia + React application
- Queue listener - Background job processing
- Vite dev server - Hot Module Replacement for React/CSS/JS
Your application will be available at http://localhost:8000 ๐
SSR Mode
To run with server-side rendering:
composer dev:ssr
๐ Authentication
Enable / Disable Registration
User self-registration is controlled by a single switch via the FORTIFY_REGISTRATION_ENABLED env variable:
FORTIFY_REGISTRATION_ENABLED=true # default โ registration is open FORTIFY_REGISTRATION_ENABLED=false # disable registration
When set to false:
- The
/registerroute is not registered and returns 404 - The "Don't have an account? Sign up" link on the login page is hidden automatically
The flag is also exposed as config()->boolean('fortify.registration_enabled') if you need to read it elsewhere in the application.
๐ Localization
The starter kit ships with full multilingual support. English (en) and Czech (cs) are included out of the box, and every user-facing string in the React frontend goes through the translator.
๐ง Switching the Locale
Set the locale in your .env file:
APP_LOCALE=cs APP_FALLBACK_LOCALE=en APP_FAKER_LOCALE=cs_CZ
After saving, the entire UI โ auth pages, settings, dashboard, navigation, validation messages โ renders in the selected language. No build step is needed for translation changes; the JSON dictionary is loaded server-side per request.
๐ Language Files
lang/
โโโ en.json # English UI strings (key โ translation)
โโโ cs.json # Czech UI strings
โโโ en/
โ โโโ auth.php # Laravel auth messages
โ โโโ pagination.php
โ โโโ passwords.php
โ โโโ validation.php # Laravel validation messages
โโโ cs/
โโโ auth.php
โโโ pagination.php
โโโ passwords.php
โโโ validation.php
*.json holds the application-level strings keyed by their English source text (Laravel's idiomatic JSON translation format). The PHP files cover Laravel's framework-level messages.
โ๏ธ Using Translations in React
The current locale and translations dictionary are shared as Inertia props by HandleInertiaRequests. Use the useTranslations hook in any component:
import { useTranslations } from '@/hooks/use-translations'; export default function MyComponent() { const __ = useTranslations(); return <h1>{__('Welcome')}</h1>; }
The hook also supports :placeholder interpolation:
__('Hello :name', { name: 'Marek' });
โ Adding a New Language
- Create
lang/{locale}.jsonwith the same keys aslang/en.json. - Create
lang/{locale}/and translateauth.php,pagination.php,passwords.php,validation.php. - Set
APP_LOCALE={locale}in.env.
๐ Code Quality
๐งน Linting & Formatting
Fix code style issues:
composer lint
This runs:
- Rector (PHP refactoring)
- Laravel Pint (PHP formatting)
- ESLint & Prettier (frontend formatting)
๐งช Testing
Run the full test suite:
composer test
This includes:
- Type coverage (100% minimum)
- Code coverage (100% required)
- Unit and feature tests (Pest)
- Code style validation
- Static analysis (PHPStan)
๐ Browser Testing
This starter kit includes Pest 4 with browser testing capabilities. Create browser tests in tests/Browser/:
it('displays the login page', function () { $page = visit('/login'); $page->assertSee(__('Log in to your account')) ->assertNoJavascriptErrors(); });
๐ Available Scripts
๐ผ Composer Scripts
composer setup- Initial project setupcomposer dev- Run all development servicescomposer dev:ssr- Run with server-side renderingcomposer lint- Fix code style issuescomposer test- Run full test suitecomposer test:unit- Run Pest tests onlycomposer test:types- Run PHPStan analysiscomposer test:type-coverage- Check type coveragecomposer test:lint- Validate code stylecomposer ci:check- Run all CI checks (lint, format, types, tests)
๐ฆ NPM Scripts
npm run dev- Start Vite dev servernpm run build- Build for productionnpm run build:ssr- Build for production with SSRnpm run lint- Fix frontend lint issuesnpm run lint:check- Check frontend lint issuesnpm run format- Format frontend code with Prettiernpm run format:check- Check frontend formattingnpm run types:check- Check TypeScript types
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.