page props undefined , `Subpage undefined` SVELTE

<script context="module">
export function load({fetch,params}){
console.log(params.id);
let id =params.id;
return {props:{id}}
}
</script>
<script>
export let id;
</script>
<div class="max-w-lg mx-auto p-4">
<h1 class="mt-20 text-2xl font-bold italic ">Subpage {id}</h1>

</div>
<script context="module">
export function load({fetch,params}){
console.log(params.id);
let id =params.id;
return {props:{id}}
}
</script>
<script>
export let id;
</script>
<div class="max-w-lg mx-auto p-4">
<h1 class="mt-20 text-2xl font-bold italic ">Subpage {id}</h1>

</div>
any solution ?
12 Replies
b1mind
b1mind2y ago
You are using a outdated version of Kit? Is there a reason for it? Cause you really should be using 1.0+ things have changed with routing and file structure.
i_lost_to_loba_kreygasm
I am following a tutorial from an year ago , maybe thats the issue 😦
b1mind
b1mind2y ago
Yea mate no go oh wait that is old too sec
b1mind
b1mind2y ago
YouTube
Learn SvelteKit
SvelteKit is the Swiss army knife of web frameworks for building resilient apps that run anywhere where JavaScript runs.
i_lost_to_loba_kreygasm
can my code not be salvaged some how ? like the module part
b1mind
b1mind2y ago
You can try running the migration script I would still start with a fresh create sveltekit app though. You can also just copy the code inside the load() function as its just moved to a different spot now. +page.js or +page.server.js make sure you understand the difference though, they made these changes to be clear about what runs on server, client, both.
i_lost_to_loba_kreygasm
i think my svelte version is ok , its the code that is old :/
b1mind
b1mind2y ago
oh then that is def a issue xD what version does it say in package.json?
i_lost_to_loba_kreygasm
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.5.0",
"autoprefixer": "^10.4.13",
"postcss": "^8.4.21",
"svelte": "^3.54.0",
"tailwindcss": "^3.2.7",
"vite": "^4.0.0"
},
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.5.0",
"autoprefixer": "^10.4.13",
"postcss": "^8.4.21",
"svelte": "^3.54.0",
"tailwindcss": "^3.2.7",
"vite": "^4.0.0"
},
b1mind
b1mind2y ago
yea so you need to be using new syntax xD and file naming/routing watch that playlist I linked you or goto https://learn.svelte.dev/tutorial/introducing-sveltekit
i_lost_to_loba_kreygasm
It has typescript FML I will try searching more
b1mind
b1mind2y ago
You don't have to use TS just ignore the TS bits ez 👏
Want results from more Discord servers?
Add your server