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

Not ready for SSR (NextJS) #452

@softmarshmallow

Description

@softmarshmallow

Trying to use this package on NextJS Proj.
Having difficulties with the itegrations.

Steps to reproduce

npx create-next-app --typescript demo
cd demo
yarn add @vscode/webview-ui-toolkit

Usage with @vscode/webview-ui-toolkit/react
in index.tsx

import React from "react"
import { VSCodeButton } from  "@vscode/webview-ui-toolkit/react";

export default function Page(){
    return (<>
        <VSCodeButton>click me</VSCodeButton>
    </>);
}

will throw

Server Error
SyntaxError: Cannot use import statement outside a module

This error happened while generating the page. Any console logs will be displayed in the terminal window.

Screenshot 2023-01-31 at 8 23 07 PM

Nor the usage with @vscode/webview-ui-toolkit

import React from "react"
import "@vscode/webview-ui-toolkit";

declare global {
  namespace JSX {
    interface IntrinsicElements {
      "vscode-progress-ring": any;
    }
  }
}


export default function Page(){
    return (<>
       <vscode-progress-ring></vscode-progress-ring>
    </>);
}

This will throw SSR error - window is not defined

Will this package be ready to be used as plug-and-play in the near future ?

Ref

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions