Skip to content

xterm.js isn't working with Next.JS #56241

Closed Answered by devjiwonchoi
Khaogamermain01 asked this question in Help
Discussion options

You must be logged in to vote

cc @Sanniv2002 @oh-joo-yeong

This is how I did:

// @/components/terminal.tsx
'use client'
export function Terminal() {
  return // ...
}
// page.tsx
'use client'
import dynamic from 'next/dynamic'

const Terminal = dynamic(
  async () => (await import('@/components/terminal')).Terminal, { ssr: false }
)

export default function Landing() {
  return <Terminal />
}

If you exported the Terminal as default:

const Terminal = dynamic(
  async () => (await import('@/components/terminal')).default, { ssr: false }
)

Replies: 4 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@devjiwonchoi
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@Sanniv2002
Comment options

@oh-joo-yeong
Comment options

@devjiwonchoi
Comment options

Answer selected by Khaogamermain01
@Khaogamermain01
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants