jianyuan / pocketbase-sveltekit-auth Goto Github PK
View Code? Open in Web Editor NEWSample SvelteKit app with PocketBase integration
Home Page: https://youtu.be/AxPB3e-3yEM
License: MIT License
Sample SvelteKit app with PocketBase integration
Home Page: https://youtu.be/AxPB3e-3yEM
License: MIT License
Hey, thanks for putting together this repo and the YouTube video.
I'm able to successfully register a user but for some reason $currentUser
is null and when I look at local storage the pocketbase_auth
is {token: '', model: null}
When I console log pb.authStore.model
in hooks.client.js
, it's null
pb.authStore.onChange(() => {
console.log('pb.authStore CHANGE', pb.authStore.model);
currentUser.set(pb.authStore.model)
document.cookie = pb.authStore.exportToCookie({ httpOnly: false })
})
Any ideas?
The logged in user's session does not get sent from the server render, causing a "flash of logged-out content".
When the client scripts kick in, the user is correctly shown as being logged in.
Here's a video showing what I mean: https://gfycat.com/tintedunrulygemsbok
This template was shared with me in pocketbase/pocketbase#2949, but I noticed that it loads a single global PocketBase instance for each request in hooks.server.ts
.
As mentioned in the above discussion, unless I'm misunderstanding the structure of the application, event.locals.pb = pb
doesn't create a new instance. It uses the same object instantiated in $lib/pocketbase.ts
.
You need to create a new PocketBase instance for each server-side request because requests from different users could write over the same pb.authStore
object.
For hooks.client.ts
is OK to have a single global PocketBase instance because the pb.authStore
in this case is kept in the user's browser and it is not shared with the other users.
My recommendation would be to create and export a function from $lib/pocketbase.ts
that will create a new PocketBase instance every time when it is called in hooks.server.ts
.
Under which license is this repository available? Please add a license file to let the users know.
I think it would be great to have loading indicators in the forms will the request is processed and also have the form fields disabled in the meantime.
Also, when there is an error, it would be great when the server actions would return the error details for frontend notices.
I totally understand, when you don't want to have all of this implemented here, to keep things simple and related to pocketbase only.
However, when you also think this would be nice to have (should not be that much boilerplate), then I could open a PR for those features.
What do you think? @jianyuan
Any tips on how to achieve this?
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are pending. To force PRs open, click the checkbox below.
@typescript-eslint/eslint-plugin
, @typescript-eslint/parser
)These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
package.json
pocketbase ^0.18.0
@sveltejs/adapter-auto ^2.1.0
@sveltejs/kit ^1.25.1
@tailwindcss/forms ^0.5.6
@tailwindcss/typography ^0.5.10
@typescript-eslint/eslint-plugin ^6.7.4
@typescript-eslint/parser ^6.7.4
autoprefixer ^10.4.16
daisyui ^3.8.3
eslint ^8.50.0
eslint-config-prettier ^9.0.0
eslint-plugin-svelte3 ^4.0.0
postcss ^8.4.31
postcss-load-config ^4.0.1
prettier ^3.0.3
prettier-plugin-svelte ^3.0.3
svelte ^4.2.1
svelte-check ^3.5.2
svelte-preprocess ^5.0.4
tailwindcss ^3.3.3
tslib ^2.6.2
typescript ^5.2.2
vite ^4.4.9
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.