<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: esriConfig.portalURL and &amp;lt;arcgis-map&amp;gt; component in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esriconfig-portalurl-and-lt-arcgis-map-gt/m-p/1715877#M88560</link>
    <description>&lt;P&gt;Do you have a small demo of this behavior?&lt;/P&gt;&lt;P&gt;I think import config and components in same module would cause this issue, depending on your app.&lt;/P&gt;&lt;P&gt;In something like React, loading config with comps should work because the render of the component happens after you probably set the config settings.&lt;/P&gt;&lt;P&gt;If you're app loads the components and the config and you already have &amp;lt;arcgis-*&amp;gt; elements on the page, then I can see where this could be an issue, they would get hydrated right away, maybe before your config set up is done.&lt;/P&gt;&lt;P&gt;Let us look at this a little further and see what can be done.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jul 2026 16:44:13 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2026-07-22T16:44:13Z</dc:date>
    <item>
      <title>esriConfig.portalURL and &lt;arcgis-map&gt; component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esriconfig-portalurl-and-lt-arcgis-map-gt/m-p/1715799#M88558</link>
      <description>&lt;P&gt;Directing applications to an Enterprise Portal can be exceptionally frustrating, as evidenced by various solved posts on here.&amp;nbsp; Using the CDN, it is&amp;nbsp;&lt;EM&gt;relatively&amp;nbsp;&lt;/EM&gt;straightforward: just ensure the esriConfig is imported before the &amp;lt;body&amp;gt;; just like the reference doc show.&lt;/P&gt;&lt;P&gt;Solution example using CDN:&lt;BR /&gt;&lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-arcgis-map-components-with-arcgis/td-p/1663763" target="_blank"&gt;How to use @arcgis/map-components with ArcGIS Ente... - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But when transitioning to ESM and using a production application bundler, the dependency tree-shaking may result in modules loading in parallel, and thus &amp;lt;components&amp;gt; still looking for arcgis.com instead of the desired portalUrl.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-js-api-map-componets-load-portal-item-not/m-p/1689444#M88270" target="_blank"&gt;Solved: ArcGIS JS API Map-Componets: Load-Portal-Item not ... - Esri Community&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/341352"&gt;@TJSimons&lt;/a&gt;&amp;nbsp;'s solution -- the accepted solution -- is to import esriConfig ahead of the entry-point, but one, this solution seems too heavily abstracted for the goal of maintaining clean code, and two, the exact syntax and placement seems likely to vary between frameworks (i.e., a quick search on emulating the Angular app.config.ts in Vite is overwhelming...).&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7384"&gt;@ReneRubalcava&lt;/a&gt;'s solution from the same thread (script in the &amp;lt;head&amp;gt; tag) -- at least in our environment -- works on a Vite/NPM dev localhost but fails after the 'build'.&amp;nbsp; Their second solution is to dynamically add the &amp;lt;arcgis-map&amp;gt; via code --&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;this works&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;but feels like it defeats the purpose of the component altogether:&lt;BR /&gt;&lt;BR /&gt;we've built on this idea but still find it a faff? (Or at worst, we simply don't understand the benefits relative to the 4.x pattern of defining a Map/View and assigning it to a container.)&amp;nbsp; &amp;nbsp;Ultimately, for our solution, we import esriConfig, then define some asynchronous function to handle creating the map component in the DOM, and finally importing the ESRI modules...&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import esriConfig from "@arcgis/core/config.js"
esriConfig.portalUrl = "yourPortalUrl"; 


// CSS Styles
import "./appStyles.css";

// Custom Modules
import * as State from    './States'
import * as Actions from  './Actions'
import * as Utils from    './utils'


async function dynamicImport(){
    import("@arcgis/map-components/components/arcgis-map");
    import("@arcgis/map-components/components/arcgis-home");
    import("@arcgis/map-components/components/arcgis-legend");
}

async function injectWebmap(){
    let mapContainer = document.getElementById("mainRight") as HTMLElement
    mapContainer.innerHTML = `
          &amp;lt;arcgis-map item-id="123abc456def"&amp;gt;
            &amp;lt;arcgis-home    slot="top-left"&amp;gt;&amp;lt;/arcgis-home&amp;gt;
			&amp;lt;arcgis-legend  slot="top-right"&amp;gt;&amp;lt;/arcgis-legend&amp;gt;
          &amp;lt;/arcgis-map&amp;gt;
    `
}

await injectWebmap()
await dynamicImport()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Aside from putting this out there for the LLM's to ingest,&lt;BR /&gt;&amp;nbsp;1. has anyone else encountered errors with the SDK appearing in 'build' but not 'dev'?&lt;BR /&gt;&amp;nbsp;2. Specifically for portalUrl, is there a cleaner or more robust solution (that is also framework-agnostic)?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2026 12:25:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esriconfig-portalurl-and-lt-arcgis-map-gt/m-p/1715799#M88558</guid>
      <dc:creator>D_Atkins</dc:creator>
      <dc:date>2026-07-22T12:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: esriConfig.portalURL and &lt;arcgis-map&gt; component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esriconfig-portalurl-and-lt-arcgis-map-gt/m-p/1715877#M88560</link>
      <description>&lt;P&gt;Do you have a small demo of this behavior?&lt;/P&gt;&lt;P&gt;I think import config and components in same module would cause this issue, depending on your app.&lt;/P&gt;&lt;P&gt;In something like React, loading config with comps should work because the render of the component happens after you probably set the config settings.&lt;/P&gt;&lt;P&gt;If you're app loads the components and the config and you already have &amp;lt;arcgis-*&amp;gt; elements on the page, then I can see where this could be an issue, they would get hydrated right away, maybe before your config set up is done.&lt;/P&gt;&lt;P&gt;Let us look at this a little further and see what can be done.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2026 16:44:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esriconfig-portalurl-and-lt-arcgis-map-gt/m-p/1715877#M88560</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2026-07-22T16:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: esriConfig.portalURL and &lt;arcgis-map&gt; component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esriconfig-portalurl-and-lt-arcgis-map-gt/m-p/1715899#M88561</link>
      <description>&lt;P&gt;I was able to recreate the error in a rather minimalistic fashion, though we did pin the issue to a particular Vite .config.&lt;BR /&gt;&lt;BR /&gt;1. We used command-line with "npx &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/create" to scaffold a Vite template.&lt;/P&gt;&lt;P&gt;2. Adapted the index.html:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;2a. Add the 'script type="module"' to the head with esriConfig.portalUrl.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;2b. Leave 'script=main.ts' as the application entry point.&lt;BR /&gt;&lt;BR /&gt;--- So far so good, this runs in dev and after build.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. We wanted a 'dashboardView.html' as a second entry point.&amp;nbsp; This naturally shares many of the basic modules written for index.html but initializes a little differently, i.e., calls a different module from the .html/body script (like "alternate.ts").&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;3a. We reconfigured the build: {rollupOptions}}:&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;build: {
  outDir: "dist",
  rollupOptions: {
	input: {
		main:      resolve(__dirname, "index.html"),
		dashboard: resolve(__dirname, "dashboardView.html"),
	},
		
  },
},&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This runs great in dev, but the 'build' dist version fails. So, the error we're getting can be chalked up to a very specific framework and very specific design goals.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;We're comfortable with our solution (adding map components and ESM imports via async functions) unless there's a clear and prudent reason to&amp;nbsp;&lt;EM&gt;not&amp;nbsp;&lt;/EM&gt;use this pattern.&amp;nbsp; The question then: is there a better way?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2026 18:02:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esriconfig-portalurl-and-lt-arcgis-map-gt/m-p/1715899#M88561</guid>
      <dc:creator>D_Atkins</dc:creator>
      <dc:date>2026-07-22T18:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: esriConfig.portalURL and &lt;arcgis-map&gt; component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esriconfig-portalurl-and-lt-arcgis-map-gt/m-p/1715906#M88562</link>
      <description>&lt;P&gt;Thanks for that! Helps with some context.&lt;/P&gt;&lt;P&gt;The more I think about it, for now anyway, is don't use the item-id directly on the map/scene component.&lt;/P&gt;&lt;P&gt;Create the webmap first, set your config props, then assign the map to to component.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import "@arcgis/map-components/components/arcgis-map";
import config from "@arcgis/core/config.js";
import WebMap from "@arcgis/.core/WebMap.js";

config.portalUrl = "mydomain.com/arcgis";
const map = new WebMap(...);
const viewElement = document.querySelector("arcgis-map");

viewElement.map = map;&lt;/LI-CODE&gt;&lt;P&gt;We'll think about this pattern some more. I think our current doc is more CDN focused here.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/authentication/access-tokens/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/authentication/access-tokens/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This sample is more about setting OAuth, but I think the same pattern would apply to setting the config props too.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/jsapi-resources/tree/main/templates/js-maps-sdk-vite" target="_blank"&gt;https://github.com/Esri/jsapi-resources/tree/main/templates/js-maps-sdk-vite&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2026 18:24:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esriconfig-portalurl-and-lt-arcgis-map-gt/m-p/1715906#M88562</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2026-07-22T18:24:14Z</dc:date>
    </item>
  </channel>
</rss>

