User Authentication with Pocketbase and SvelteKit | Full Auth Solution

Опубликовано: 21 Май 2026
на канале: Consulting Ninja
5,110
89

This is part 6 in the PocketBase series. In this video I show how to implement user authentication using PocketBase and SvelteKit. This is a full authentication solution. I first show how to register a user. Then we setup our hooks.server file to keep our authentication up to date and send user information to all our routes through locals using ( PocketBases built in methods exportToCookie, loadFromCookie, and authRefresh functions). Then we log a user in using a login route and PocketBases authWithPassword on the user collection. Then we move to a protected route that only allows access to authenticated users and also pulls out some user info to display it. Lastly I show how to implement a logout button. On the way I also cover removing pre-load on the links to prevent errors on the auth and logout routes! Lots of good stuff in this one! I hope that you find this helpful!

My channel membership is live check it out here!:
   / @consultingninja  

Membership perk video:
   • I launched a chatbot with my channel membe...  
Need help? visit https://www.consultingninja.tech
Check out my channel @ConsultingNinja for more videos like these.

Source Code Available Here:
https://github.com/consultingninja/pb...

PocketBase Increase Security when using http (Part 5) Here:
   • Add these lines to your SvelteKit Pocketba...  

PocketBase Realtime DB Subscriptions Video (Part 4) Here:
   • Realtime Data Subscriptions with PocketBas...  

PocketBase Google Auth App Video (Part 3) Here:
   • OAuth2 using Google, PocketBase, and Svelt...  

PocketBase CRUD App Video (Part 2) Here:
   • Create a CRUD App with PocketBase and Svel...  

PocketBase Overview & Setup Video (Part 1) Here:
   • PocketBase | what it is | how to run it | ...  

PocketBase Docs:
https://pocketbase.io/docs/

PocketBase JavaScript SDK:
https://github.com/pocketbase/js-sdk