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

AppSync, AWS Amplify and SSR #1613

Open
romainquellec opened this issue Sep 11, 2018 · 21 comments

Comments

@romainquellec
Copy link

commented Sep 11, 2018

AppSync, AWS Amplify and SSR :
Hi ! Is Amplify (GraphQL Client) is SSR compatible ? Can't find any information on docs right now. Thanks !

@undefobj

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2018

@romainquellec

This comment has been minimized.

Copy link
Author

commented Sep 18, 2018

Well, in this example, you re not using amplify. I will migrate all this with apollo and appsync, but for now, I just want amplify with SSR. Is this possible ?

@romainquellec

This comment has been minimized.

Copy link
Author

commented Sep 27, 2018

The answer is : no, you can't.

@Enalmada

This comment has been minimized.

Copy link

commented Oct 19, 2018

@romainquellec Can you elaborate? I am considering building an AppSync react native app for a client and an admin interface to manage things is a requirement. A Next.js Amplify AppSync admin client "backend" would be ideal. Is Amplify with Next.js really not possible?

Seems like people might have gotten amplify working with SSR by using cookie authentation and an isomorphic fetch: #493 (comment) Are there problems beyond that?

@romainquellec romainquellec reopened this Oct 20, 2018

@romainquellec

This comment has been minimized.

Copy link
Author

commented Nov 5, 2018

@littleone2018

This comment has been minimized.

Copy link

commented Jan 27, 2019

i only want seo, can amplify work with sth like prerender.io?

@ajhool

This comment has been minimized.

Copy link

commented Feb 7, 2019

Any luck with amplify and next.js? @Enalmada @romainquellec

@romainquellec

This comment has been minimized.

Copy link
Author

commented Feb 12, 2019

I cant help, I'm now using apollo and appsync for the GraphQL part.

@skdigital

This comment has been minimized.

Copy link

commented Feb 14, 2019

Its a real shame that nextjs is not compatible with AWS Amplify, its a massive short fall in my eyes.

@kjetilge

This comment has been minimized.

Copy link

commented Feb 15, 2019

I'm having the same issue. Maybe it would it be possible/easy to trigger prerendering of routes from a lambda function ? Perhaps using PrerenderSPAPlugin ?

@romainquellec

This comment has been minimized.

Copy link
Author

commented Feb 15, 2019

The specific GraphQL part was not SSR compatible (months ago).
I'm using Auth and Storage with Next with no problem (for now).

    "@aws-amplify/auth": "^1.2.15",
    "@aws-amplify/core": "^1.0.22",
    "@aws-amplify/storage": "^1.0.25",

...

    "apollo-cache-inmemory": "^1.4.2",
    "apollo-client": "^2.4.12",
    "apollo-link-http": "^1.5.11",
    "aws-appsync": "^1.7.1",

is OK.

@romainquellec

This comment has been minimized.

Copy link
Author

commented Feb 15, 2019

And you still could load some components with component with React if something is broken.

@ngocketit

This comment has been minimized.

Copy link

commented Feb 15, 2019

I'm using Amplify with Appsync and Nextjs and it works pretty ok. I had a setup where I use Api key on server and Cognito user pool on client. SSR is for public, anonymous user so you don't need to handle authentication etc. For all the protected pages that require user login, I render it on client.

@romainquellec

This comment has been minimized.

Copy link
Author

commented Feb 20, 2019

Closing this. There is (at least) one issue on SSR improvement for aws-amplify.

@ajhool

This comment has been minimized.

Copy link

commented Mar 7, 2019

I'm not sure why this issue was closed. This is an ongoing issue that I think a lot of people will stumble upon as nextjs and amplify grow in popularity.

@skdigital

This comment has been minimized.

Copy link

commented Mar 8, 2019

I agree this shouldn't be closed.. I, along with many others are holding our breath for amplify support for server rendered apps.

@ajhool

This comment has been minimized.

Copy link

commented Mar 9, 2019

@skdigital what are you looking for in particular? I have a nextjs workaround that I think is robust, although the workaround is just to deter Amplify from doing anything on the server

@skdigital

This comment has been minimized.

Copy link

commented May 3, 2019

@ajhool

I am looking to use nextjs and host via zeit now.

Use only Amplify for Auth, Storage, and Appsync realtime DB graphql with offline functionality.

Is this possible and advisable for production? (hosting somewhere else, so we can use nextjs)?

@ajhool

This comment has been minimized.

Copy link

commented May 3, 2019

I would highly recommend building a test app, first, that attempts the integrations you plan on using. If you'd like, I can create an open source example to show my integration strategies. I'm using react.

The only problem I've had, so far, is Amplify Auth + next. I have used Storage and Api(Appsync - not realtime) without any issues. All of my Api calls are coming from the client, so I'm not sure if Api/Appsync will work on the server, especially if the calls require authentication.

One of the main frustrations has been that the Amplify team does not currently fully support not-breaking-SSR** in the Amplify framework. However, the team is also extraordinarily helpful and responsive, they just have not been responsive on the SSR issue; I expect that to change as more people request SSR compatibility. Also, because amplify is an open source project provided by AWS, it seems that the official AWS support center does not actually provide support -- this policy, to me, does not make sense, but the lack of official support is worth considering for a production environment.

The other frustration is that next/now/zeit team is not very responsive or supportive. The software is convenient and worth it, but when it breaks it can be hard to find a fix. Thus, I highly recommend a barebones test app before integrating your entire app (as I tried to do).

**By not-breaking-ssr, I mean that the framework does not need to actual render on the server-side, but it should not break server-side rendering. Currently, simply importing certain Amplify components (eg. aws-amplify-react/Authenticator) has broken SSR without any clear error or debug opportunities.

@gcid12

This comment has been minimized.

Copy link

commented May 29, 2019

@romainquellec , I also think you should keep this ticket open. There's a lot you can do with Amplify But well supported, well documented, production ready Server Side is a must for a lot of us. Would love to hear from @undefobj if this is in the roadmap, he's usually very responsive.

@undefobj undefobj reopened this May 29, 2019

@undefobj

This comment has been minimized.

Copy link
Contributor

commented May 29, 2019

SSR support is on our roadmap, and we'd like to do it this year but for transparency it's not in the next few months. It will require a fair amount of work on the internals and potentially some breaking changes so we would like to do it as part of a larger release this summer/fall with other changes. That being said if anyone in the community wishes to fork Amplify and try to get it working, then give feedback on what was required to get things working (even if it's a PR we don't merge) then that would help us accelerate the work.

I've reopened this issue for tracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.