Vue 3: Props are visible using the element inspector #372
-
I have this problem with Inertiajs and Vue3 where props are visible when I do inspect element. Is it okay? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 23 replies
-
This is totally expected behaviour. All data that you pass from your server-side framework to Inertia is publicly available. As noted from the docs:
|
Beta Was this translation helpful? Give feedback.
-
@BlueSilver001 Still not completly hiding it but removing it after the app is mounted, you may try out the following. import { createApp, h, onMounted } from 'vue';
import { App, plugin } from '@inertiajs/inertia-vue3';
const el = document.getElementById('app');
createApp({
setup() {
onMounted(() => {
delete el.dataset.page;
});
},
render: () =>
h(App, {
initialPage: JSON.parse(el.dataset.page),
resolveComponent: name => require(`./Pages/${name}`).default,
}),
})
.use(plugin)
.mount(el); |
Beta Was this translation helpful? Give feedback.
-
You can basically do this: createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
setup({el, App, props, plugin}) {
const application = createApp({render: () => h(App, props)})
.use(plugin)
.use(ZiggyVue, Ziggy)
.mount(el);
delete el.dataset.page
return application;
},
progress: {
color: '#4B5563',
}, So what we've done here is save the creation of the vue Instance into a variable called application, then after the data-page have been parsed we delete the attribute, and the return the application instance |
Beta Was this translation helpful? Give feedback.
This is totally expected behaviour. All data that you pass from your server-side framework to Inertia is publicly available.
As noted from the docs: