Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

feat(nuxt): server-only components#9972

Merged
danielroe merged 9 commits intomainfrom
feat/server-components-2
Jan 9, 2023
Merged

feat(nuxt): server-only components#9972
danielroe merged 9 commits intomainfrom
feat/server-components-2

Conversation

@danielroe
Copy link
Copy Markdown
Member

🔗 Linked issue

resolves nuxt/nuxt#11856
closes #5688

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Summary

This PR builds on #5689 to add support for registering and rendering server components with .server.vue suffix (implementing nuxt/nuxt#11856).

Usage

Standalone server components will always be rendered on the server. When their props update, this will result in a network request that will update the rendered HTML in-place.

Server components are currently experimental and in order to use them, you need to enable the 'component islands' feature in your nuxt.config:

export default defineNuxtConfig({
  experimental: {
    componentIslands: true
  }
})

Now you can register server-only components with the .server suffix and use them anywhere in your application automatically.

| components/
--| HighlightedMarkdown.server.vue
<template>
  <div>
    <!--
      this will automatically be rendered on the server, meaning your markdown parsing + highlighting
      libraries are not included in your client bundle.
     -->
    <HighlightedMarkdown markdown="# Headline" />
  </div>
</template>

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added enhancement New feature or request 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing labels Jan 6, 2023
@danielroe danielroe requested review from antfu and pi0 January 6, 2023 14:30
@danielroe danielroe self-assigned this Jan 6, 2023
@codesandbox
Copy link
Copy Markdown

codesandbox Bot commented Jan 6, 2023

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@danielroe danielroe mentioned this pull request Jan 6, 2023
6 tasks
Copy link
Copy Markdown
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Other than small comments, neat work 💯

Comment thread docs/content/1.docs/2.guide/2.directory-structure/1.components.md
Comment thread packages/nuxt/src/components/loader.ts
Comment thread packages/nuxt/src/components/templates.ts
@vercel vercel Bot temporarily deployed to Preview January 9, 2023 10:30 Inactive
@vercel vercel Bot temporarily deployed to Preview January 9, 2023 11:16 Inactive
Copy link
Copy Markdown
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

💯

@danielroe danielroe merged commit 2d013c5 into main Jan 9, 2023
@danielroe danielroe deleted the feat/server-components-2 branch January 9, 2023 11:20
@nikodunk
Copy link
Copy Markdown

A test-MR is working nicely for us for the new Fedora Linux website, and we can't wait to start using it in production once 3.1 ships. Thanks so much for adding this feature! https://gitlab.com/fedora/websites-apps/fedora-websites/fedora-websites-3.0/-/merge_requests/247

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.x enhancement New feature or request 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Server only components

3 participants