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

feat(nuxt): server-only components - #9972

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

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

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

resolvesnuxt/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:

exportdefaultdefineNuxtConfig({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. --><HighlightedMarkdownmarkdown="# Headline" /></div></template>

📝 Checklist

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

@danielroedanielroe 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 pi0January 6, 2023 14:30
@danielroedanielroe self-assigned this Jan 6, 2023
@codesandbox

Copy link
Copy Markdown

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

@danielroedanielroe mentioned this pull request Jan 6, 2023
6 tasks
pi0
pi0 approved these changes Jan 6, 2023

@pi0pi0 left a comment

Copy link
Copy Markdown
Member

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 threadpackages/nuxt/src/components/loader.ts
Comment threadpackages/nuxt/src/components/templates.ts
pi0
pi0 approved these changes Jan 9, 2023

@pi0pi0 left a comment

Copy link
Copy Markdown
Member

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 mainJan 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 freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xenhancementNew feature or request🍰 p2-nice-to-havePriority 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

@danielroe@nikodunk@pi0