Skip to content

Equivalent of Next.js getServerSideProps in Aleph? #22

Closed
@khromov

Description

@khromov

I was reading the documentation about the useDeno hook and it says:

In Next.js, two functions called getStaticProps and getServerSideProps are used by the pages to fetch data at build time(SSR) or on each request. This solution isolates the data and view likes different roles of the back-end and front-end.

In Aleph.js, we prefer the mixed solution, a react hook called useDeno provided that allows you fetch data at build time(SSR) in a component with Deno runtime, that's more React Style likely:

After reading the examples, it appears you can only use the getStaticProps approach from Next (ie. fetching data at build time), but that there is no way to use the getServerSideProps approach?

A common use case for this that I don't understand how to solve in Aleph:

  • I have a site that needs to fetch some data locked behind a Bearer token. I want to pass this data as the initial props data to the component. I don't want this code in the frontend bundle.
  • I don't plan to hydrate this data on the frontend at all after initial load.

Is this use case not supported in Aleph? If not, it hampers the functionality to unusable levels for our projects. If it is indeed possible, can you please document how to use useDeno together with dynamic SSR that can fetch data on each request?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions