Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set application name dynamically in single-spa-router ? #168

Open
MirtoBusico opened this issue May 18, 2022 · 0 comments
Open

How to set application name dynamically in single-spa-router ? #168

MirtoBusico opened this issue May 18, 2022 · 0 comments

Comments

@MirtoBusico
Copy link

Hi all,
I'm trying to create a route that call an application with the same name of the route.

For now I have two applications ("u-app1" and "u-app2") that are called when the path is equal to application name ("/u-app1" and "/u-app2") and this works:

<single-spa-router>
  <!--

    This is the single-spa Layout Definition for your microfrontends.
    See https://single-spa.js.org/docs/layout-definition/ for more information.

  -->
  <div class="w3-container w3-blue">
    <main class="w3-row">
      <div class="w3-col s3 ">
        <application name="@user-frontend/u-header"></application>
        <application name="@user-frontend/u-nav"></application>
      </div>
      <div class="w3-col s9">
        <route path="u-app1">
          <application name="@user-frontend/u-app1"></application>
        </route>

        <route path="u-app2">
          <application name="@user-frontend/u-app2"></application>
        </route>

        <route default>
          <h1 style="padding: 30px;">U-VIEW application</h1>
        </route>
      </div>
    </main>
  </div>
</single-spa-router>

Now I'm trying to use the path as a variable to select the application; but I don't know how to do it
In my mind this can be a pseudo code:

<single-spa-router>
  <!--

    This is the single-spa Layout Definition for your microfrontends.
    See https://single-spa.js.org/docs/layout-definition/ for more information.

  -->
  <div class="w3-container w3-blue">
    <main class="w3-row">
      <div class="w3-col s3 ">
        <application name="@user-frontend/u-header"></application>
        <application name="@user-frontend/u-nav"></application>
      </div>
      <div class="w3-col s9">

        <route path="/:appname">
          <application name=params.appname></application>
        </route>

        <route default>
          <h1 style="padding: 30px;">U-VIEW application</h1>
        </route>
      </div>
    </main>
  </div>
</single-spa-router>

How can I pass the path variable as the application name?

@filoxo filoxo transferred this issue from single-spa/single-spa May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant