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

feat(nuxt): server-only components #9972

Merged
merged 9 commits into from
Jan 9, 2023
Merged

Conversation

danielroe
Copy link
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 pi0 and antfu January 6, 2023 14:30
@danielroe danielroe self-assigned this Jan 6, 2023
@codesandbox
Copy link

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
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 πŸ’―

@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
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

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