All questions

Backend is Laravel with Blade templates, can we use Croct without a JS framework?

Asked by tiago on

Ttiago

Hi all. Our whole stack is Laravel with Blade templates rendered server-side, no SPA anywhere and honestly no plans for one.

We want to add personalization to a few landing pages. Every example I find assumes React or Next.js though. Is there an actual PHP path here, or would we be forced to bolt a JS framework onto the site just for this?

Would love to keep everything in Blade if possible

Cheers

Was this helpful?

1 answer

MmkaminskiAccepted answer

You are covered, no JS framework needed. There is a dedicated PHP SDK, and the docs have specific pages for Laravel, Symfony, and Drupal on top of the generic PHP one. You fetch the slot content server-side in your controller and pass it to the Blade view like any other data, so the rendered HTML already carries the personalized content.

Two details worth knowing:

  • The CLI generates a slots.stub file for PHP projects, which is the equivalent of the slots.d.ts file TypeScript users get. Your IDE picks up the slot content shapes from it.
  • If you later want client-side event tracking (clicks, custom goals), you can drop in the script tag or the JS SDK alongside the server-side fetch. They work together fine, the server does the rendering and the client does the tracking.

We run a similar Laravel setup and never touched React for it.

Was this helpful?
Ttiago

Great news, the slots.stub detail is a nice touch. Will start with server-side only and add the script tag later. Cheers!

Still have questions?