Blazor for v6?

Has anyone gotten v6 to work with Blazor yet/has an example repo I could look at?

I’ve tried adding the npm packages but haven’t figured out how to get it to work just yet. As an example, here is my index.js:

import {basicSetup, EditorView} from "codemirror"
import {EditorState, Compartment} from "@codemirror/state"
import {python} from "@codemirror/lang-python"

let language = new Compartment, tabSize = new Compartment

let state = EditorState.create({
    extensions: [

let view = new EditorView({
    parent: document.body

function setTabSize(view, size) {
        effects: tabSize.reconfigure(EditorState.tabSize.of(size))

My Index.razor looks like:

@page "/"
@inject IJSRuntime JSRuntime;

<textarea id="codearea">select * from test</textarea>

<br />
<br />

Input Code: @UserCodeInput


    public string UserCodeInput { get; set; }

    protected override async Task OnAfterRenderAsync(bool firstRender)
        if (firstRender)
            await JSRuntime.InvokeVoidAsync("window.initCodeMirror");

    public Task UpdateField(string codeValue)
        UserCodeInput = codeValue;
        return Task.CompletedTask;

And my _Host.cshtml is:

@page "/"
@namespace BlazorApp1.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
    Layout = "_Layout";

<component type="typeof(App)" render-mode="ServerPrerendered"/>

<!DOCTYPE html>
    <link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
    <link href="css/app.css" rel="stylesheet" />
<script src="_framework/blazor.webassembly.js" autostart="false"></script>
<script src="js/index.bundle.js"></script>
window.initCodeMirror = function () {
    var textArea = document.getElementById('codemirror');
    var editor = CodeMirror.fromTextArea(textArea);

    editor.on('change', function () {
        textArea.innerHTML = editor.getValue();
        textArea.dispatchEvent(new Event('change', { bubbles: true }));

The error message I keep getting is:

CodeMirror is not defined

Which I assume is because that’s v5 syntax, but I’m not sure where to go from here. Any help would be greatly appreciated!

Did you get it to work?

I made a working example in Blazor. It’s pretty basic right now, I will be adding more features and publishing as an official Nuget package.

Check it out here: GitHub - gaelj/BlazorCodeMirror6: Blazor wrapper for CodeMirror 6