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

docs: add api functionality docs (#30436) #30437

Merged

Conversation

bootsmann1995
Copy link
Contributor

@bootsmann1995 bootsmann1995 commented Jan 2, 2025

🔗 Linked issue

resolves #30436

📚 Description

Adds documentation around the use of ssr:false and server/api. This provides a better understading on what deployment strategy should be used for your app using ssr:false

Copy link

stackblitz bot commented Jan 2, 2025

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

coderabbitai bot commented Jan 2, 2025

Warning

Rate limit exceeded

@danielroe has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 33 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between e3b859c and cec9556.

📒 Files selected for processing (1)
  • docs/2.guide/1.concepts/3.rendering.md (1 hunks)

Walkthrough

The pull request introduces comprehensive documentation updates for Nuxt rendering modes, focusing on deployment configurations and rendering strategies. The changes provide detailed guidance on handling Single-Page Application (SPA) mode, static client-rendered applications, and hybrid rendering approaches.

The documentation elaborates on critical deployment considerations, such as the implications of using ssr: false and the recommended build processes for maintaining API functionality. It introduces configuration options like routeRules in nuxt.config.ts for defining route-specific rendering and caching strategies, as well as new options for prerendering and caching behaviours.

Additionally, a new warning regarding the limitations of nuxi generate and nuxi build --prerender is included, along with an expanded section on adjusting prerendering settings. The update also features practical examples demonstrating how to configure route rules and manage different rendering modes across various routes.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
docs/2.guide/1.concepts/3.rendering.md (3)

95-97: Enhance the explanation of API functionality

The warning about API functions being removed is crucial, but it would be more helpful to explain:

  1. Why npm run generate removes the server API functions
  2. What are the implications for different deployment scenarios
  3. How to properly configure the server when using npm run build

Consider expanding the section with this additional context:

-Deploying Nuxt using `npm run generate` with `ssr:false` removes the `~/server/api` functions. Consider using `npm run build` for `~/server/api` endpoints to work correctly.
+Deploying Nuxt using `npm run generate` with `ssr:false` removes the `~/server/api` functions because it generates a static site without a server component. If your application requires API functionality:
+
+1. Use `npm run build` instead, which preserves the server runtime
+2. Deploy to a hosting platform that supports server-side functionality
+3. Ensure your deployment process includes starting the Nitro server

98-108: Clarify the purpose of prerendered routes in SPA mode

The configuration example would be more helpful with explanations of why each route is necessary:

Consider expanding the section with this additional context:

-If running your app in `npm run build` mode with `ssr:false`, remember to add `["200.html", "404.html" "/" ]` to your `nitro.prerender` configuration to ensure your app functions work in Single-Page Application (SPA) mode.
+If running your app in `npm run build` mode with `ssr:false`, you need to prerender specific routes for proper SPA functionality:
+
+- `200.html`: Serves as the default success page for client-side routing
+- `404.html`: Handles non-existent routes gracefully
+- `/`: Ensures the root route is properly handled
+
+Add these routes to your `nitro.prerender` configuration:

230-238: Fix grammatical and formatting issues in example descriptions

The word "todos" should be hyphenated as "to-dos" for correct grammar.

Apply these corrections:

-  title: Nuxt Todos Edge
+  title: Nuxt To-dos Edge
   ---
-  A todos application with user authentication, SSR and SQLite.
+  A to-dos application with user authentication, SSR and SQLite.
🧰 Tools
🪛 Markdownlint (0.37.0)

231-231: Expected: atx; Actual: setext
Heading style

(MD003, heading-style)

🪛 LanguageTool

[grammar] ~232-~232: It appears that a hyphen is missing in the plural noun “to-dos”?
Context: ...on: i-simple-icons-github title: Nuxt Todos Edge to: https://github.com/atinux/nu...

(TO_DO_HYPHEN)


[grammar] ~238-~238: It appears that a hyphen is missing in the plural noun “to-dos”?
Context: ...: text-black dark:text-white --- A todos application with user authentication, S...

(TO_DO_HYPHEN)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61ddea1 and e6f60b3.

📒 Files selected for processing (1)
  • docs/2.guide/1.concepts/3.rendering.md (3 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/2.guide/1.concepts/3.rendering.md

[uncategorized] ~109-~109: Loose punctuation mark.
Context: ....html", "404.html"], } }, }) ``` ::tip{to="https://www.youtube.com/watch?v...

(UNLIKELY_OPENING_PUNCTUATION)


[grammar] ~232-~232: It appears that a hyphen is missing in the plural noun “to-dos”?
Context: ...on: i-simple-icons-github title: Nuxt Todos Edge to: https://github.com/atinux/nu...

(TO_DO_HYPHEN)


[grammar] ~238-~238: It appears that a hyphen is missing in the plural noun “to-dos”?
Context: ...: text-black dark:text-white --- A todos application with user authentication, S...

(TO_DO_HYPHEN)

🪛 Markdownlint (0.37.0)
docs/2.guide/1.concepts/3.rendering.md

198-198: Expected: atx; Actual: setext
Heading style

(MD003, heading-style)


231-231: Expected: atx; Actual: setext
Heading style

(MD003, heading-style)


243-243: Expected: atx; Actual: setext
Heading style

(MD003, heading-style)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
docs/2.guide/1.concepts/3.rendering.md (2)

104-106: Important clarification about server endpoints!

The warning effectively communicates the limitations of prerendering commands. Consider enhancing it with a code example demonstrating a typical server endpoint that wouldn't work with prerendering.

Here's a suggested addition:

 If you prerender your app with the `nuxi generate` or `nuxi build --prerender` commands, then you will not be able to use any server endpoints as no server will be included in your output folder. If you need server functionality, use `nuxi build` instead.
+
+For example, this server endpoint would not work with prerendering:
+```ts
+// server/api/hello.ts
+export default defineEventHandler(() => {
+  return { message: 'Hello from the server!' }
+})
+```
🧰 Tools
🪛 LanguageTool

[uncategorized] ~105-~105: Loose punctuation mark.
Context: ...unctionality, use nuxi build instead. :: If you are using purely client-side r...

(UNLIKELY_OPENING_PUNCTUATION)


95-95: Remove extra blank line

There are multiple consecutive blank lines here. Please remove one blank line to maintain consistent formatting throughout the documentation.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~95-~95: Loose punctuation mark.
Context: ...n/nuxt-config#spaloadingtemplate"} :: ::tip{to="https://www.youtube.com/watch?v...

(UNLIKELY_OPENING_PUNCTUATION)

🪛 Markdownlint (0.37.0)

95-95: Expected: 1; Actual: 2
Multiple consecutive blank lines

(MD012, no-multiple-blanks)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6f60b3 and e3b859c.

📒 Files selected for processing (1)
  • docs/2.guide/1.concepts/3.rendering.md (2 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/2.guide/1.concepts/3.rendering.md

[uncategorized] ~95-~95: Loose punctuation mark.
Context: ...n/nuxt-config#spaloadingtemplate"} :: ::tip{to="https://www.youtube.com/watch?v...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~105-~105: Loose punctuation mark.
Context: ...unctionality, use nuxi build instead. :: If you are using purely client-side r...

(UNLIKELY_OPENING_PUNCTUATION)

🪛 Markdownlint (0.37.0)
docs/2.guide/1.concepts/3.rendering.md

95-95: Expected: 1; Actual: 2
Multiple consecutive blank lines

(MD012, no-multiple-blanks)

🔇 Additional comments (1)
docs/2.guide/1.concepts/3.rendering.md (1)

95-95: Excellent addition of multimedia learning resource!

The video reference is well-placed and provides valuable supplementary content for developers learning about SPA development with Nuxt.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~95-~95: Loose punctuation mark.
Context: ...n/nuxt-config#spaloadingtemplate"} :: ::tip{to="https://www.youtube.com/watch?v...

(UNLIKELY_OPENING_PUNCTUATION)

🪛 Markdownlint (0.37.0)

95-95: Expected: 1; Actual: 2
Multiple consecutive blank lines

(MD012, no-multiple-blanks)

@danielroe danielroe merged commit 7a5fd9b into nuxt:main Jan 4, 2025
4 checks passed
@github-actions github-actions bot mentioned this pull request Jan 4, 2025
danielroe pushed a commit that referenced this pull request Jan 4, 2025
@github-actions github-actions bot mentioned this pull request Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSR False configuration missing documentation on building in generate mode.
2 participants