1 hour ago · Tech · hide · 0 comments

At Spatie we build SaaS apps with Laravel on the backend and Inertia with React on the frontend. That split means two type systems have to agree about every payload that crosses between them. Laravel data going out, TypeScript picking it up. There There, the helpdesk we're building, is built exactly like that. Tickets, messages, members, custom sidebar sections, all of it crosses the bridge. We'd go insane maintaining those types by hand. So we don't. There There is in private beta right now, and you can apply for early access at there-there.app. Two Spatie packages make this painless. spatie/laravel-data shapes outgoing payloads into typed PHP classes, and spatie/laravel-typescript-transformer turns those classes into TypeScript definitions at build time. Let me show what that looks like in practice. Keeping types in sync A payload starts life as a Data class. Here's our MemberData, which we send down every time we render the member detail page. use Spatie\LaravelData\Data; use…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.