SSR support
See original GitHub issueI am currently exploring Pocketbase using their Pocketbase Js with Remix Js. The problem is that I can’t adapt the operation of AuthStore with each request to the server.
Suggestion: To solve the drawback can an additional parameter to set the token manually.
pocketbaseClient.Users.getOne('idUser', {}, 'User eyJh...')
[Original] Compatibilidad con SSR
Actualmente estoy explorando Pocketbase usando su Pocketbase Js con Remix Js. El problema es que no puedo adaptar el funcionamiento de AuthStore con cada petición al servidor.
Sugerencia: Para solucionar el inconveniente pueden un parámetro adicional para poner el token manualmente
Issue Analytics
- State:
- Created a year ago
- Comments:24 (15 by maintainers)
Top Results From Across the Web
Server-Side Rendering - Vite
Vite provides built-in support for server-side rendering (SSR). The Vite playground contains example SSR setups for Vue 3 and React, which can be...
Read more >SSR Support for AWS Amplify JavaScript Libraries
Enabling Server-Side Rendering (SSR) support in an Amplify app. When using the Amplify CLI, the aws-exports.js file gets created and updated ...
Read more >Server-Side Rendering (SSR) - Vue.js
Vite SSR # ... Vite provides built-in support for Vue server-side rendering, but it is intentionally low-level. If you wish to go directly...
Read more >Superior Support Resources Inc.
SSR's experts can resolve issues from password resets and software questions to equipment failure and device configuration.
Read more >Using Server-side Rendering (SSR) - Gatsby
Introduction Server-side Rendering (SSR) is one of Gatsby's rendering options and allows you to pre-render a page with data that is…
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’ve explored the available options the last couple of days, but I couldn’t find a “one size fit all” solution, so I’ve implemented the following in the latest v0.6.0 SDK release:
I’ve added 2 cookie helper methods to the
BaseAuthStoreto simplify working with cookies:I’ve added some examples for SvelteKit (based on @ollema suggestion), Nuxt 3 and Next.js in https://github.com/pocketbase/js-sdk#ssr-integration.
The above should help (or at least to give you some idea) how to deal with SSR, but if someone still have difficulties making it work, feel free to let me know and I’ll try to provide some guidance based on your use case.
@ganigeorgiev figured I would give an update on the
AuthStoresituation with SvelteKit SSR.After doing some research it seems like this is the most “idiomatic” approach (for now, SvelteKit is still not 1.0 so things could change!):
Like you suggested you would use a new client instance for each request/response.
In SvelteKit, this could be handled in the
handlefunction inhooks.ts.src/hooks.tsBy setting
event.locals.pocketbasetoclient, the client will be available in handlers in+server.tsand server-onlyloadfunctions (handle docs)In the
handlefunction above, I have also populatedevent.locals.userwith the current user if the token is valid.Now, while the
handlefunction above can be used to access the client and/or the current user in SSR, how do we authenticate a user or in other words store the token and (user)model?If I understood it correctly, you would create server endpoints for this, for example:
src/routes/auth/signin/+server.tsand
src/routes/auth/signout/+server.tsIt should be noted that the snippets above do not have any error handling, they can just be seen as inspiration.
To update the profile of the currently logged in user, you could add an additional
/auth/saveroute for example.Final thoughts
AuthStorecan be used today with the help ofhooks.tsand some server endpointsAuthStorethat could simplify the method above would be very nice!AuthStorefor SSR will be added - then maybe (a revised) version of this method (and similar versions for other frameworks) could be added to the docs?