{"id":15622045,"url":"https://github.com/talyssonoc/react-laravel","last_synced_at":"2025-04-08T01:36:44.383Z","repository":{"id":29897241,"uuid":"33442882","full_name":"talyssonoc/react-laravel","owner":"talyssonoc","description":"Package for using ReactJS with Laravel","archived":false,"fork":false,"pushed_at":"2019-11-27T08:21:41.000Z","size":261,"stargazers_count":897,"open_issues_count":16,"forks_count":90,"subscribers_count":40,"default_branch":"master","last_synced_at":"2025-04-01T00:34:25.100Z","etag":null,"topics":["laravel","php","react","server-side-rendering"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/talyssonoc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-05T14:16:57.000Z","updated_at":"2025-01-17T23:02:48.000Z","dependencies_parsed_at":"2022-08-24T14:01:36.943Z","dependency_job_id":null,"html_url":"https://github.com/talyssonoc/react-laravel","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talyssonoc%2Freact-laravel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talyssonoc%2Freact-laravel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talyssonoc%2Freact-laravel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talyssonoc%2Freact-laravel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/talyssonoc","download_url":"https://codeload.github.com/talyssonoc/react-laravel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247761051,"owners_count":20991531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","php","react","server-side-rendering"],"created_at":"2024-10-03T09:52:39.977Z","updated_at":"2025-04-08T01:36:44.364Z","avatar_url":"https://github.com/talyssonoc.png","language":"PHP","funding_links":[],"categories":["Packages"],"sub_categories":["JavaScript Framework Support"],"readme":"[![Code Climate](https://codeclimate.com/github/talyssonoc/react-laravel/badges/gpa.svg)](https://codeclimate.com/github/talyssonoc/react-laravel) [![Build Status](https://travis-ci.org/talyssonoc/react-laravel.svg?branch=master)](https://travis-ci.org/talyssonoc/react-laravel)\n\n# react-laravel\n\nWith `react-laravel` you'll be able to use [ReactJS](https://facebook.github.io/react/) components right from your Blade views, with optional server-side rendering, and use them on the client-side with React due to unobtrusive JavaScript.\n\n# Installation\n\n## V8js dependency\n\nIt's important to know that `react-laravel` has an indirect dependency of the [v8js](https://pecl.php.net/package/v8js) PHP extension.\n\nYou can see how to install it here: [how to install v8js](install_v8js.md).\n\n## Composer\n\nSet the `minimum-stability` of your `composer.json` to `dev`, adding this:\n\n```json\n  \"minimum-stability\": \"dev\"\n```\n\nThen run:\n\n```sh\n  $ composer require talyssonoc/react-laravel:0.11\n```\n\nAfter that you should add this to your providers at the `config/app.php` file of your Laravel app:\n\n```php\n  'React\\ReactServiceProvider'\n```\n\nAnd then run:\n\n```sh\n  php artisan vendor:publish\n```\n\nAnd the `react.php` file will be available at the `config` folder of your app.\n\n# Usage\n\nAfter the installation and configuration, you'll be able to use the `@react_component` directive in your views.\n\nThe `@react_component` directive accepts 3 arguments:\n\n```php\n  @react_component(\u003ccomponentName\u003e[, props, options])\n\n  //example\n  @react_component('Message', [ 'title' =\u003e 'Hello, World' ], [ 'prerender' =\u003e true ])\n\n  // example using namespaced component\n  @react_component('Acme.Message', [ 'title' =\u003e 'Hello, World' ], [ 'prerender' =\u003e true ])\n```\n\n* `componentName`: Is the name of the global variable that holds your component.  When using [Namespaced Components](https://facebook.github.io/react/docs/jsx-in-depth.html#namespaced-components) you may use dot-notation for the component name.\n* `props`: Associative of the `props` that'll be passed to your component\n* `options`: Associative array of options that you can pass to the `react-laravel`:\n  * `prerender`: Tells react-laravel to render your component server-side, and then just _mount_ it on the client-side. Default to __true__.\n  * `tag`: The tag of the element that'll hold your component. Default to __'div'__.\n  * _html attributes_: Any other valid HTML attribute that will be added to the wrapper element of your component. Example: `'id' =\u003e 'my_component'`.\n\nAll your components should be inside `public/js/components.js` (you can configure it, see below) and be global.\n\nYou must include `react.js`, `react-dom.js` and `react_ujs.js` (in this order) in your view. You can concatenate these files together using laravel-elixir.\n\n`react-laravel` provides a ReactJS installation and the `react_us.js` file, they'll be at `public/vendor/react-laravel` folder after you install `react-laravel` and run:\n\n```sh\n  $ php artisan vendor:publish --force\n```\n\nFor using the files provided by `react-laravel` and your `components.js` file, add this to your view:\n\n```html\n  \u003cscript src=\"{{ asset('vendor/react-laravel/react.js') }}\"\u003e\u003c/script\u003e\n  \u003cscript src=\"{{ asset('vendor/react-laravel/react-dom.js') }}\"\u003e\u003c/script\u003e\n  \u003cscript src=\"{{ asset('js/components.js') }}\"\u003e\u003c/script\u003e\n  \u003cscript src=\"{{ asset('vendor/react-laravel/react_ujs.js') }}\"\u003e\u003c/script\u003e\n```\n\nIf you'll use a different version from the one provided by react-laravel (see `composer.json`), you got to configure it (see below).\n\n# Configurations\n\nYou can change settings to `react-laravel` at the `config/react.php` file:\n\n```php\n  return [\n    'source' =\u003e 'path_for_react.js',\n    'dom-source' =\u003e 'path_for_react-dom.js',\n    'dom-server-source' =\u003e 'path_for_react-dom-server.js',\n    'components' =\u003e [ 'path_for_file_containing_your_components.js' ]\n  ];\n```\n\nAll of them are optional.\n\n* `source`: defaults to `public/vendor/react-laravel/react.js`.\n* `dom-source`: defaults to `public/vendor/react-laravel/react-dom.js`.\n* `dom-server-source`: defaults to `public/vendor/react-laravel/react-dom-server.js`.\n* `components`: defaults to `public/js/components.js`. Multiple components files may be specified here.\n\nYour `components.js` file(s) should also be included at your view, and all your components must be at the `window` object.\n\n# Thanks\n\nThis package is inspired at [react-rails](https://github.com/reactjs/react-rails).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalyssonoc%2Freact-laravel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftalyssonoc%2Freact-laravel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalyssonoc%2Freact-laravel/lists"}