Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT]: Add SSR application #21

Closed
brandonroberts opened this issue Aug 9, 2022 · 11 comments
Closed

[FEAT]: Add SSR application #21

brandonroberts opened this issue Aug 9, 2022 · 11 comments

Comments

@brandonroberts
Copy link
Member

Vite has built-in support for SSR https://vitejs.dev/guide/ssr.html

This application could serve as the starting point for using Analog applications with SSR, and a baseline for future support of api/server routes.

@mainawycliffe
Copy link
Contributor

mainawycliffe commented Aug 22, 2022

Will this use an express server or are there going to be a few alternatives to choose from?

@brandonroberts
Copy link
Member Author

Good question. Most likely we'll start with express and see what other options are available.

Some type of NestJS integration would be interesting but not sure it's possible.

@Yberion
Copy link
Contributor

Yberion commented Aug 23, 2022

I'm sure a Fastify version could be done as well.

If I understand correctly, we can already make an example app with Vite SSR using Angular Universal Engine (Common/Clover) as renderer?

If so, are you fine with the example app not being Standalone since Angular Universal doesn't support it yet?

@mainawycliffe
Copy link
Contributor

@brandonroberts What do you mean by NextJS integration?

This one issue I would love to explore and see if I can pull it off, but I would need some guidance on the way to approach it.

@brandonroberts
Copy link
Member Author

@mainawycliffe I was referring NestJS https://nestjs.com/

@Yberion I have a sample repo here that uses SSR without Angular Universal https://github.com/brandonroberts/analog-angular-ssr

Vite already handles the additional pieces.

@mainawycliffe
Copy link
Contributor

mainawycliffe commented Aug 23, 2022

@brandonroberts ah, that makes sense. For a moment I was like what kind of witchery are you proposing with Nextjs, would be exciting though.

@Yberion
Copy link
Contributor

Yberion commented Aug 23, 2022

@Yberion I have a sample repo here that uses SSR without Angular Universal https://github.com/brandonroberts/analog-angular-ssr

Vite already handles the additional pieces.

I tried on my side with Angular Universal last week but I was missing some knowledges (selectors & renderApplication, angular.default()). Thanks for making that implementation!

Do you still require a PR for this issue (mostly copy/paste what you did) or you will do it yourself?

@mainawycliffe
Copy link
Contributor

Taking a look at the repo you shared, and it looks quite nice. To do SSR, we would need to load the individual route and get component details from it and do SSR, am I right?

@brandonroberts
Copy link
Member Author

@Yberion its not complete. It doesn't handle serving a production build. It just shows that it works.

@mainawycliffe Yes, if you have the routing setup with the Angular Router it should just SSR the app similar to how universal does it.

Long term this would be integrated inside the plugin itself. We could add some docs on using this as is today with an existing setup

@mainawycliffe
Copy link
Contributor

I am just mentally modeling how the plugin would work; with analog and maybe express or nestjs, we would automatically check the route being accessed in the routes directly and SSR the page. The tricky part I can think of is to fallback to CSR so that it behaves like a SPA after the first load (maybe I am thinking to far ahead) and lazy loads the routes just like a normal angular application, but we could generate a server bundle and client bundle to work around this.

Next.js has a Link component that enables this behavior for CSR, we could follow a similar path.

@yackinn
Copy link

yackinn commented Oct 17, 2022

I'm interested in creating an implementation with NestJS.
It could be similar to this https://github.com/nxarch/nest-nguniversal.

What are these middlewares used for?

app.use(vite.middlewares);

Villanuevand pushed a commit to Villanuevand/analog that referenced this issue Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants