Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rishabhy's avatar

What are steps and code laravel 9 API backend code when make chat app using socket.io in reactnative

We are going to make chat app using socket.io in reactnative frontend and backend laravel 9 . What will be laravel 9 backend API code for chat , would anyone kindly tell us that what are steps for laravel 9 backend and also what will code for laravel 9 backend with frontend reactnative using socket.io

0 likes
5 replies
martinbean's avatar

@rishabhy This isn’t a forum where you say “we are going to build a chat app”… and then ask people to give you the code for a chat app.

1 like
kokoshneta's avatar

And if you are going to build the app, why are you using an old version of Laravel that’s not even maintained or supported anymore? Laravel 9 reached EOL three weeks ago.

richarditsme's avatar

The Steps for Laravel Backend: Install Laravel 9:

Set up a new Laravel project. Install required dependencies for WebSocket and broadcasting. Install and Configure WebSockets:

Use beyondcode/laravel-websockets for WebSocket support. Publish and configure WebSocket settings in config/websockets.php. Setup Broadcasting:

Configure the broadcasting driver to use WebSockets (websockets). Set the appropriate .env values for broadcasting and queue handling (BROADCAST_DRIVER=websockets, CACHE_DRIVER=redis, etc.). Create Event for Chat Messages:

Use Laravel's event broadcasting to create a MessageSent event. This event will broadcast new messages to the WebSocket channel (ShouldBroadcast). Define API Routes:

Create API endpoints to handle sending and receiving messages. Start WebSocket Server:

Run php artisan websockets:serve to start the WebSocket server. Connect React Native Frontend:

Use socket.io-client to listen for real-time events from the Laravel WebSocket server and emit new messages.

Please or to participate in this conversation.