Skip to content

Conversation

tnylea
Copy link
Contributor

@tnylea tnylea commented Mar 4, 2025

This PR will fix the warnings and errors when running the starter kit using Inertia SSR.

Test this out by running:

npm run build:ssr
php artisan inertia:start-ssr

You can also run:

composer run dev:ssr

Which is a new script that's added to the composer.json to run the SSR functionality.

You can also test this out by disabling javascript in the browser. If it's SSR, everything will work with Javascript Disabled; otherwise if you are running the default composer run dev the pages will not render if you disable javascript; rightfully so.

This PR has a similar PR on the react starter kit: laravel/react-starter-kit#53


return [
...parent::share($request),
return array_merge(parent::share($request), [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this array_merge() necessary? The React version doesn't use it, though either the spread or the merge will accomplish the same thing. Just wanted to double check so we can keep consistency between the React/Vue templates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right you are, we could use the spread operator here. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this file be ssr.ts instead? There's no JSX being used, so probably not necessary to have that as the file type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I'll get that updated.

@taylorotwell taylorotwell merged commit c4b9cf5 into main Mar 6, 2025
2 checks passed
@taylorotwell taylorotwell deleted the ssrFix branch March 6, 2025 18:49
D4ve-R pushed a commit to D4ve-R/vue-starter-kit that referenced this pull request Mar 11, 2025
* Adding initial SSR fixes

* fixing warning messages in SSR

* Adding updates to ssr file to include global route var

* Adding dev:ssr command

* Adding light/dark mode fixes to support cookies and localstorage

* updating the intertia return array

* formatting

* run formatter

---------

Co-authored-by: Taylor Otwell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants