@@ -38,25 +38,30 @@ void createInertiaApp({
3838 } ,
3939
4040 setup ( { el, App, props } ) {
41- if ( el ) {
42- // Uncomment the following to enable SSR hydration:
43- // if (el.hasChildNodes()) {
44- // hydrateRoot(el, createElement(App, props))
45- // return
46- // }
47- createRoot ( el ) . render ( createElement ( App , props ) )
48- } else {
49- console . error (
50- "Missing root element.\n\n" +
51- "If you see this error, it probably means you load Inertia.js on non-Inertia pages.\n" +
52- 'Consider moving <%= vite_typescript_tag "inertia" %> to the Inertia-specific layout instead.' ,
53- )
54- }
41+ // Uncomment the following to enable SSR hydration:
42+ // if (el.hasChildNodes()) {
43+ // hydrateRoot(el, createElement(App, props))
44+ // return
45+ // }
46+ createRoot ( el ) . render ( createElement ( App , props ) )
5547 } ,
5648
5749 progress : {
5850 color : "#4B5563" ,
5951 } ,
52+ } ) . catch ( ( error ) => {
53+ // This ensures this entrypoint is only loaded on Inertia pages
54+ // by checking for the presence of the root element (#app by default).
55+ // Feel free to remove this `catch` if you don't need it.
56+ if ( document . getElementById ( "app" ) ) {
57+ throw error
58+ } else {
59+ console . error (
60+ "Missing root element.\n\n" +
61+ "If you see this error, it probably means you loaded Inertia.js on non-Inertia pages.\n" +
62+ 'Consider moving <%= vite_typescript_tag "inertia" %> to the Inertia-specific layout instead.' ,
63+ )
64+ }
6065} )
6166
6267// This will set light / dark mode on load...
0 commit comments