benallfree / pbscript

Typescript/JavaScript serverless cloud functions for PocketBase
11 stars 1 forks source link

support for SSR? #1

Closed jkdoshi closed 1 year ago

jkdoshi commented 1 year ago

Thanks for starting pbscript. It's a great companion to pocketbase.

My default strategy with pocketbase is to use SvelteKit frontend, and make it as static (JAMStack) as possible. But sometimes dynamic code at runtime is still needed. For example:

  1. When you want to have a runtime API endpoint to generate runtime results.
  2. Or when you need runtime SSR of a page (imagine a site with local business listings of 50,000 cities; not practical to prerender them all).

pbscript (I think) would be useful in scenario #1, but perhaps not in scenario #2? Technically, SSR is still just script execution, but maybe I don't know enough about pbscript to see how it would work.

Eventually, it would be nice to have a SvelteKit adapter that generates JS code that simply runs in pbscript.

PS: I put this in as an issue, since "discussions" feature is not turned on yet.

benallfree commented 1 year ago

Pocketbase exposes a hook API written and Go. Normally, other customizations must be written in Go and re-compiled. PBScript allows you to write hook handlers in Typescript or JavaScript instead of Go.

SvelteKit would do all the SSR handling. If you were to use the PocketBase js sdk client during an SSR request, that should work because the client will work in a node environment.

Did I understand your question correctly?

benallfree commented 1 year ago

Closing this issue due to inactivity.