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

SSR -> CSR #15

Merged
merged 20 commits into from
Apr 5, 2024
Merged

SSR -> CSR #15

merged 20 commits into from
Apr 5, 2024

Conversation

VortexExpansion
Copy link
Contributor

@VortexExpansion VortexExpansion commented Mar 20, 2024

Fixes #14
https://github.com/diverta/front_kuroco_document_site/issues/957

Reviewer

@yabe-diverta san

Key changes

  • SSR=false in nuxt config
  • UseFetch -> $fetch and server=false in all API params
  • <ClientOnly> tag for default.vue

Progress check

  • Set SSR to false
  • Company
  • Contact
  • Login
  • ltd-news
  • mypage
  • news
  • preview
  • privacy
  • service
  • composables
  • index and layout

@VortexExpansion VortexExpansion marked this pull request as ready for review March 20, 2024 09:15
@VortexExpansion
Copy link
Contributor Author

@yabe-diverta san
Please review

Copy link
Collaborator

@yabe-diverta yabe-diverta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you provide general loader for fallback?

If you do use ssr: false, you should also place an HTML file in ~/app/spa-loading-template.html with some HTML you would like to use to render a loading screen that will be rendered until your app is hydrated.

see https://nuxt.com/docs/guide/concepts/rendering

layouts/default.vue Outdated Show resolved Hide resolved
pages/company/index.vue Show resolved Hide resolved
pages/contact/index.vue Outdated Show resolved Hide resolved
pages/index.vue Outdated Show resolved Hide resolved
pages/news/detail/[id].vue Outdated Show resolved Hide resolved
pages/preview/content.vue Outdated Show resolved Hide resolved
pages/preview/ltd-news.vue Show resolved Hide resolved
pages/preview/news.vue Show resolved Hide resolved
pages/privacy/index.vue Outdated Show resolved Hide resolved
pages/service/index.vue Show resolved Hide resolved
Copy link
Collaborator

@yabe-diverta yabe-diverta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set request changes

@VortexExpansion
Copy link
Contributor Author

VortexExpansion commented Mar 28, 2024

@yabe-diverta san

Since most of the reviews are related to $fetch v/s useFetch, I will address it here.

I agree behaviour-wise while generating there would be no difference between $fetch and useFetch but my understanding is that $fetch is a basic fetch request whereas useFetch has an added layer of complexity that even though performs the same task, but has no advantage of being used here.

I prefer using $fetch everywhere because

  • maintaining consistency in all fetch calls across all requests
  • it is recommended by nuxt3 documentation to use $fetch if fetch is client side only
  • useFetch is preferred in SSR and its only use is to prevent data fetching twice in case of SSR. Since we don't plan on using SSR, we get no benefit of using useFetch which is almost equivalent to useAsyncData(url, () => $fetch(url))

References :
https://nuxt.com/docs/api/utils/dollarfetch
https://nuxt.com/docs/getting-started/data-fetching
https://nuxt.com/docs/api/composables/use-fetch

@yabe-diverta
Copy link
Collaborator

@VortexExpansion

I thought:

  • Yes sure there is no advantages while we select CSR, if we keep useFetch(), users could freely switch to SSG when they want.
  • Plus for me, some event handler fns we have added are using $fetch().
    This is explicitly labeling those functions are supposed only used in client-side, not server-side.

Although,

it is recommended by nuxt3 documentation to use $fetch...

I could not find that sentence out in doc site, could you share me?
I will agree with setting $fetch() instead of useFetch() if true.

@VortexExpansion
Copy link
Contributor Author

@yabe-diverta san
I agree with both your points.

it is recommended by nuxt3 documentation to use $fetch if fetch is client side only

Reference
https://diverta.gyazo.com/13ea0ce1378ced7302d481ef5cd182c0
https://diverta.gyazo.com/d6a5a436123a0750a9b84b103f8bdc17

@yabe-diverta
Copy link
Collaborator

@VortexExpansion
Thank you for clarification 🙇
Hmm for me it sounds they don't recommend using $fetch over navigations & initializations (general use-cases) but over client-side event handler.

@VortexExpansion
Copy link
Contributor Author

@yabe-diverta san
Understood. So, in conclusion, I will stick to this. Please confirm.

  • Yes sure there is no advantages while we select CSR, if we keep useFetch(), users could freely switch to SSG when they want.
  • Plus for me, some event handler fns we have added are using $fetch(). This is explicitly labeling those functions are supposed only used in client-side, not server-side.

@VortexExpansion
Copy link
Contributor Author

VortexExpansion commented Apr 1, 2024

@yabe-diverta san
Reflected all requested changes
Please confirm

Copy link
Collaborator

@yabe-diverta yabe-diverta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed, pleas check 🙇

pages/preview/ltd-news.vue Outdated Show resolved Hide resolved
pages/preview/news.vue Outdated Show resolved Hide resolved
pages/service/index.vue Outdated Show resolved Hide resolved
@takel-shiba
Copy link
Collaborator

@yabe-diverta
修正確認お願いします

Copy link
Collaborator

@yabe-diverta yabe-diverta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed again, no issues found 🙇

@yabe-diverta yabe-diverta merged commit 96c587e into diverta:main Apr 5, 2024
@yabe-diverta yabe-diverta deleted the csr branch April 5, 2024 06:28
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

Successfully merging this pull request may close these issues.

フロントエンドへの反映方法に差異がある
3 participants