Embed independent components in existing site
I have an existing site built entirely in Aurelia. As a demo to my organization regarding Blazor, I would like to replace a single existing component. In Aurelia it is possible to extend an existing application by calling an enhance method and providing a DOM selector.
Is there any way to accomplish something similar with Blazor?
Long term it would be nice to be able to import arbitrary components independent of them being rendered client side and hosted on CDN or server side and rendered by Azure.
Yes, you can render a Blazor component into any DOM element. That's how the app startup process works: your Program.cs (or Startup.cs in 0.5.0+) nominates which component to render into which DOM element.
Thank you for responding, I've done some prototyping following your advice and I have to say this is extremely encouraging!
I can see now that everything is dependent on the imported blazor.server.js file, and as long as i reference that file in my existing html it will bootstrap and render blazor to the component specified in my startup.
I am interested in taking this to the next step and using two completely separate solutions side by side, with each being responsible for rendering a different component.
Would this approach be possible or will i receive conflicts on globally namespaces resources?
I did some further testing of the idea I asked about above and got an error:

For server B, which provides the blazor.server.js file to server A,I used the following: Startup.cs
public void Configure(IBlazorApplicationBuilder app)
{
app.AddComponent<HistoryFeed>("HistoryFeedMicroserviceTwo");
}
Index.html
<!DOCTYPE html>
<html>
<head>
<title>Server Side Blazor</title>
</head>
<body>
<div>You shouldn't see this in master project.</div>
<div>The blazor.server.js script import has been removed because otherwise the project crashes due to not being able to locate a HistoryFeedMicroserviceTwo tag to render the component into.</div>
</body>
</html>
historyfeed.cshtml
@page "/historyfeed"
<div>Hello World 2</div>
For server A, which imports the blazor.server.js script of server B, I have the following configuration: Startup.cs
public void Configure(IBlazorApplicationBuilder app)
{
app.AddComponent<HistoryFeed>("HistoryFeedMicroservice");
}
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width">
<title>Server Side Blazor</title>
<base href="/" />
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="css/site.css" rel="stylesheet" />
</head>
<body>
<HistoryFeedMicroserviceTwo></HistoryFeedMicroserviceTwo>
<HistoryFeedMicroservice></HistoryFeedMicroservice>
<script src="_framework/blazor.server.js"></script>
<script src="http://localhost:50827/_framework/blazor.server.js"></script>
</body>
</html>
HistoryFeed.cshtml
@page "/historyfeed"
<div>Hello World 1</div>
Could you provide any advice on how to move forward this direction?
Don't load blazor.server.js twice into the same frame. Like most JavaScript files, it can only be loaded once.
You need there to be only one .NET entrypoint. Your single .NET entrypoint can make multiple calls to IBlazorApplicationBuilder's AddComponent method to add separate components in separate DOM elements.
That solution works well so long as all blazor components used in a single site are able to be deployed within a single visual studio solution. I would like to be able to have one division of my organization publish their JS file, another publish theirs, and have each team responsible for their component as microservices, independent of each other. This limitation would also prevent using components authored by several 3rd parties in an HTML only fashion.
I attempted to modify the index.html file to have two differently named script tags, hoping that may resolve the issue, but unfortunately it did not:
<script src="_framework/blazor.server.js"></script>
<script src="http://localhost:50827/_framework/blazor.server2.js"></script>
Would it be possible / difficult to allow multiple instances of the component framework?
edit: please don't take this the wrong way, what you have already provided is 95% of what I think is important, and I'm going to run with it as is! it would just be cool to arbitrarily serve up components by just loading their JS file, and have each of them able to load balance independently of the rest of the application.
That's not really a model we're focusing on today, any more than having multiple solutions combined at runtime into a single ASP.NET Core server-side site. ASP.NET Core as a whole expects composition to be at the .NET project level, not at the "separate .NET solution deployed to different servers" level. I'm sure with some creative hacking you might find some way to do it that way, but I don't have any direct recommendations about it.
I completely understand, its an edge case for sure, and what you have already delivered covers the core values and is absolutely phenomenal. I'm officially a blazor evangelist!