Protecting resources with a Protected Layout and slots in Svelte / SvelteKit

Often times, we'll have pages that need to be protected and expect a user to be logged in. We covered the basics of doing this previously with the settings page, but we want to make sure we can do this anywhere without repeating too much code. We can easily do this with "slots" from Svelte and layout files from SvelteKit. In this episode I show how to do that.
🤯 Support
  • https://www.patreon.com/davidwparker
  • https://www.buymeacoffee.com/davidwparker

⏱️ Timestamps:
  • 00:00 - Introduction
  • 00:38 - Demo
  • 01:15 - Nav changes
  • 01:50 - About changes
  • 02:10 - Settings changes
  • 03:20 - Protected Layout
  • 05:00 - Other ways to do this

💌 Newsletter:
  • https://www.programmingtil.com/

🪐Elsewhere:
  • Twitter: https://twitter.com/davidwparker
  • Twitter: https://twitter.com/programmingtil
  • GitHub: https://github.com/davidwparker

💭Concepts:
  • Slots in Svelte
  • Layouts

📚Resources:
  • https://github.com/davidwparker/programmingtil-svelte/tree/ep18
  • https://kit.svelte.dev/docs#layouts
  • https://svelte.dev/docs#slot

🎬 Subscribe!
  • http://bit.ly/subdavidwparker

My name is David W Parker and I’m creating and publishing videos on ProgrammingTIL to help teach anyone and everyone who wants to code. I’m a huge fan of Ruby on Rails, Svelte, TailwindCSS, and WebGL. I’ve used React a lot in the past, as well as some Vue and AngularJS. I’ve done some professional Python and Django. I like to create real applications and my tutorials will walk you through how to build something real from beginning-to-end.

svelte #sveltekit

© programmingtil.com