My visit to the cemetery with Tyler Henry, America’s most famous 28-year-old psychic medium.
ByEmily Gould,
a novelist, critic, and features writer for New York Magazine.She writes the ‘Going Through It' advice column and is most recently the author of ‘Perfect Tunes.’
Photo: Jamie Lee Taete
Photo: Jamie Lee Taete
Photo: Jamie Lee Taete
It’s a chilly, overcast day, and fog wreaths the monuments at the Hollywood Forever Cemetery in Los Angeles, driving away all but the most determined tourists. Still, little groups of people in twos and threes are making their way among the gravestones and mausoleums, taking note of the movie stars and very rich people buried here, and all of them — literally all of them — interrupt Tyler Henry’s photo shoot to politely ask him for a selfie.
I assumed he would have some celebrity sightings of his own (what I wouldn’t give to hear from Judy Garland, who’s laid to rest right nearby). After all, the 28-year-old Henry is one of the most famous psychic mediums alive, with three TV series under his belt, a long list of celebrity clients (a handful of Kardashians, RuPaul, and Allison Janney, to name a few), and a 700,000-person waiting list for readings. But for Henry, cemeteries are dead silent; spirits only come to him via their living relatives, he tells me in a secluded corner of the Cathedral Mausoleum as he sips one of the six venti iced lattes he drinks every day. But when he does, as he puts it, “open those floodgates” during a reading, “you never know what’s going to come out.”
Every Tuesday, on his new Netflix show Live From the Other Side, he sits down with a celebrity and performs his trademark reading, holding objects that belonged to deceased loved ones his guests are hoping will “come through,” scribbling in his notebook as he focuses on their energies, and listening for their voices. In spite of being about ceasing to corporeally exist, Henry’s shows are somehow as cozy and upbeat and backgroundish as HGTV.
The key to the winning formula is Henry’s oddball charisma. He still looks almost exactly as youthful as he did when viewers first encountered him nearly a decade ago, with the same floppy blond mop, soulful deep-brown eyes, and easy megawatt grin. He’s here at the cemetery with his mom, Theresa, who drives him everywhere because he never learned (“I feel like if I don’t have to do it, why should I?” he says, not unreasonably). They don’t live together anymore — he moved in with his partner, Clint, four years ago — but she still makes him dinner that they eat together every night, which is often plain pasta with grated cheddar cheese. He can’t really go to the grocery store because there are so many people’s psychic energies swirling around there, and also so many people who want selfies, which is why his assistants or Clint or his mom usually handle the mundane tasks of life, like acquiring those Starbucks iced lattes. He keeps his circle small, and after work, he’s glad to come home to them. “They view me more as a person than a medium.”
Henry’s abilities as a psychic medium started early. At 10, he had a premonition of his grandmother’s death, which was confirmed by a phone call a few minutes later. After that, the communications from the other side came thick and fast, and Henry at first had no idea how to handle them. He would tell kids at school things they didn’t even know about their own families, just because those facts were available to him. His high-school math teacher Trishaa Camp was an early believer in his abilities, after he pulled her aside on the day her mother-in-law died and simply told her, “It’s okay to cry.” It was the first of many unsolicited readings from him. “He’d be like, ‘Hey, your brother’s here.’ I’m like, ‘What?’ He’s like, ‘Your brother’s here. He wants to know how your husband’s doing,’” Camp told me. “I’m like, ‘Tyler, we need to focus.’” And not only was he psychic — he was also gay. It was a lot for a raised-religious kid from an industrial town in California’s San Joaquin Valley. “I grew up in a culture that in many ways did not want me to be myself,” Henry tells me. Henry survived his awkward teen years with help from Camp, who got him on a track to graduate early at 16. He had to make an escape.
Henry began giving readings for $35 in the area’s only occult bookstore, the Cosmic Corral, and word spread. Sarah Paulson wound up hearing about him from some friends who’d gotten a reading from him there, and she called him up to request a session with him that she remembers as “wonderful and sweet.” Their meeting got Henry an invite to a Christmas party in L.A. where he met talent managers Larry Stern and Michael Corbett. The next day, Henry did readings for both of them. Corbett handed Henry a watch, and “it got really real really quick,” Henry says. The watch belonged to a friend who had recently died by suicide, and they came through with specific information about how they passed. “It was pretty shocking,” Corbett told me. “No one knew those details.”
After that, Stern and Corbett rounded up a group of ten friends and shot a sizzle reel of Henry reading them back-to-back over the course of two days in Stern’s backyard. They showed it to the executives at E!, who were into it but wanted to add a celebrity element, and thus Hollywood Medium With Tyler Henry was born. On each episode, Henry would show up to the homes of E!-grade celebrities like Amber Rose, Snooki, and Lil Jon and do readings for them. Occasionally, the cameras captured an honest moment of embarrassment when Henry didn’t recognize the person he was meeting.
Photo: Jamie Lee Taete
After four seasons of reading for celebrities, Henry embarked on his most personal show, Life After Death, in 2022. Slower-paced, with the vibe and music cues of a reality-documentary style show, the series features Henry driving around the U.S. and giving readings to people randomly selected from his waiting list. He also tries to find Theresa’s birth mother, who gave her up for adoption under mysterious circumstances that neither psychic nor traditional research seem fully able to penetrate.Though Henry’s able to discover other people’s secrets, when he tries to read his mom, he comes up empty.
To skeptics who think that assistants or producers must be feeding Henry Googleable information about the people he’s reading beforehand, I can only report that everyone on his team is a true believer. Henry’s worked with the same crew throughout this career: his managers Stern and Corbett, his assistant Heather, his mom, and Clint. Stern became emotional while telling me about how Henry had helped him process loss in his own life, and everyone around him seems almost parentally protective of him. While I was talking to them, and especially while I was talking to Henry, I found myself wholly under his spell.
While watching his shows, though, it can be hard to sustain that kind of wholehearted belief.Though he rarely tells anyone anything they didn’t already know, the drama is in the space between what he professes to know going into the reading — nothing — and what he says when he starts scribbling. “Oh, this is interesting,” he’ll begin, or “Oh, that’s weird.” He might have a physical reaction — a tightness in his chest or difficulty breathing. Soon, we learn how the loved one died — gunshot, drowning, blood clot, mudslide. But lest this cause any distress, Henry reassures his client that the passing was quick, painless, or expected. Now, the loved one is here and happy. So far, any reasonably convincing actor could pull this off, but then comes the unnerving part. “He’s doing a little dance — I can’t do it, I’m a terrible dancer — like this,” Henry tells one grieving mother on Life After Death as he awkwardly wiggles his hips. And it’s exactly the way her son used to dance, and there is simply no way he could have known that. He manages to pull out some intangible detail or gesture like that maybe half the time, but that still seems like a lot. In those moments, I was sold on Henry. But the corny music cues and the insistence that those who have crossed over are full of joy have an oddly flattening effect. Even if Henry’s communications with spirits are 100 percent authentic, there’s something weird about how quickly the show transitions from tragedy to uplift almost instantaneously. It’s almost like it doesn’t give death enough credit.
It’s very rare for the living to hear from Henry that their deceased family members disapprove of any of their decisions, and sometimes spirits have immense changes of heart after passing over. Henry conveyed such a message to Brad Bessey, the director of communications for a food bank that Henry has volunteered with for several years. During her life, Bessey’s mother had strongly disapproved of him being gay and especially didn’t feel comfortable with the fact that he and his husband were adopting a child. She died without changing her mind about the appropriateness of Bessey’s family. But 16 years later, during Henry’s reading, her spirit came through with an entirely different message: one of radical acceptance. Just as he did on the show, Bessey tears up when telling me about it over the phone. “What I needed to hear was a validation that my mom from the other side was checking in, watching, and was proud of the job I was doing as a father,” he says. “That was so moving.”
Photos: Jamie Lee Taete.
Photos: Jamie Lee Taete.
Photo: Jamie Lee Taete
When comedian Nikki Glaser got the offer to be on Henry’s new show, her management said she didn’t have time in her schedule. She told them to move things around. “I was like, ‘You don’t understand the waiting list!’” Her taping went well, she thought, though there were some moments that didn’t quite land, like when Henry tried to deliver a message intended for her friend to her mother — the spirits had their lines crossed, it seemed. “I walked away from it being like, listen, I can’t say a hundred percent that it’s real. All I know is that if it’s not, I don’t even care,” she says. “Do you know why? If it’s not real, it’s not because Tyler’s doing something to trick us. It’s giving people hope that there’s an afterlife. It’s giving people closure with their loved ones.” Her sister’s now going to get a cancer screening because of something Henry alluded to during the taping.
When I ask Henry if he ever questions whether the information he’s transmitting is accurate, he surprises me by admitting that he isn’t aiming for perfection. “I still sometimes am wrong,” he says. “I aim to be about 80 percent on.” He sometimes compares himself to a mailman, just delivering a message. But he’s okay with his odds. “I just kind of trust the process.”
On one episode of Life After Death, Henry visits his old elementary school and reminisces about what life was like before his psychic ability began to manifest. Things were simpler before the spirit presences, and before fame. “In order to survive, I’ve carved out a life for myself,” he says. “In my free time, the last thing I’m inclined to do is go to a club or go to a rave.” Early episodes of Hollywood Medium showed an assistant trying to get him to go out and party in L.A., but that plotline was quickly dropped.
His physical health has been imperiled for as long as he’s been famous. Around the time he started working on his first show, he started experiencing debilitating headaches and was diagnosed with a benign cyst in his brain that must be routinely drained when it gets too big, since it’s too dangerous to remove entirely. (“I have wondered if it relates to my ability at all,” Henry says.) He also suffered from a collapsed lung in 2019, and he has congenital blebs — small air-filled cysts — on his lungs, which must also be monitored. There are a lot of doctor’s appointments. Henry attributes these issues to the toll his work takes on his body and compares himself to a professional basketball player who keeps getting injured. “It’s the biggest question I have: Why, if this is something of a gift, does it come at a cost?” he says.
Photo: Jamie Lee Taete
Stopping isn’t an option, either. If he goes too long without doing readings, feelings that aren’t his own begin crowding his consciousness. “If I want to take three weeks off, by week No. 2, I start feeling a little funny and even funnier and even funnier,” he tells me. “Why do I feel a connection to a divorced mother? Why do I feel sadness over not calling my alcoholic son? I don’t have an alcoholic son.” He has described the feeling as being “spiritually constipated.”
“I’m here for a good time, not necessarily here for a long time,” he says with his trademark smile. I ask him my last burning question: Will he and Clint ever get married? They’re getting hitched in December, actually, after rejecting an October 30 wedding date for being “too creepy.” Henry’s looking forward to the milestone. More than most people, he’s aware of life’s transience. As we gaze around at the gravestones and mausoleums that surround us, Henry reflects on his own eventual death. “Mortality is a constant in my life, in my work, in my personal life with my health struggles, death has touched every aspect,” he says. “And so when it comes time, it’ll be okay. I genuinely feel cool with it.” Left unsaid, because to Henry it’s obvious, is that believing you’ll be able to check in with your loved ones from the spirit realm probably makes death seem like much less of a big deal.
By submitting your email, you agree to our
Terms and Privacy Notice
and to receive email correspondence from us. This site is protected by reCAPTCHA and the Google
Privacy Policy and
Terms of Service apply.
or
Already a subscriber?
What is your email?
This email will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
Password must be at least 8 characters and contain:
Lower case letters (a-z)
Upper case letters (A-Z)
Numbers (0-9)
Special Characters (!@#$%^&*)
This password will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
You’re in!
As part of your account, you’ll receive occasional updates and offers from New York, which you can opt out of anytime.
or
Already a subscriber?
What is your email?
This email will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
Password must be at least 8 characters and contain:
Lower case letters (a-z)
Upper case letters (A-Z)
Numbers (0-9)
Special Characters (!@#$%^&*)
This password will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
You’re in!
As part of your account, you’ll receive occasional updates and offers from New York, which you can opt out of anytime.
Already a subscriber?
Already a subscriber?
`;
// integrate Sub(x) scripts and elements
if (hostname !== 'subs.nymag.com') { // do not integrate on this subdomain
document.head.appendChild(trackingScript);
document.body.insertAdjacentHTML('beforeend', subXAnimationElements);
}
There was an error processing the request. Please try again later."}).catch(e=>console.error("Error verifying email: ",e)))(r.querySelector(".content"),o.bannerCTAVerification)})):(l.remove(),s.remove()),o.dismissable||n.remove(),o.useAlertIcon||a.remove(),r.classList.add("show"),n.addEventListener("click",()=>{u(),r.classList.remove("show")})}else r.remove()}});
}, {"1":1,"6":6,"12":12,"35":35,"40":40}];
window.modules["global-nav.client"] = [function(require,module,exports){"use strict";const dom=require(4),auth=require(12),signInButton=dom.find(".user-signin"),signOutButton=dom.find(".user-signout"),globalNav=dom.find('[class^="global-nav"]'),body=dom.find("body"),dropdownItems=dom.findAll(".dropdown-wrap"),gtm=require(1),appendLandingPageParams=require(135),pageUri=require(124).getPageUri(),subscriptionPromoLinks=dom.findAll(".persist-params"),searchString=window.location.search||"";function closeDropdowns(e){let n=globalNav.querySelectorAll(".dropdown.open");dropdownItems.forEach(function(t){let o=t.querySelector(".dropdown");!n||t.contains(e.target)&&27!==e.keyCode||o.classList.remove("open")})}function gtmSendReport(e,n,t){let o={eventCategory:"ecommerce",eventAction:"componentClick",brand:e,dimension23:"global-nav",list:pageUri,pageZone:"header",variant:"nav-link"};"global-nav-link"===t&&(o.eventLabel=n.href),gtm.reportNow(o)}function updateElementTargetUrlsIfQueryStrings(e){if(searchString){const n=new URLSearchParams(searchString);let t=e.href;if(t.includes("?")){const o=t.split("?"),i=new URLSearchParams(o[1]);for(let e of n.entries())i.set(e[0],e[1]);t=`${o[0]}?${i.toString()}`,e.href=t}else e.href=`${t}?${n.toString()}`}}function init(e){const n=e.querySelectorAll(".to-landing-page");window.addEventListener("auth:init",()=>{signInButton.addEventListener("click",function(e){e.preventDefault(),auth.showEmbeddedLoginFlow("top navigation")}),signOutButton.addEventListener("click",function(e){e.preventDefault(),gtmSendReport("Sign Out",e.target,"user-info-link"),auth.logout()}),auth.isAuthenticated()&&e.classList.add("signed-in"),auth.isSubscriber()&&e.classList.add("subscribed"),e.querySelectorAll(".user-link").forEach(e=>{e.classList.add("active")}),subscriptionPromoLinks.forEach(e=>{updateElementTargetUrlsIfQueryStrings(e)}),appendLandingPageParams(n)})}dropdownItems.forEach(function(e){e.addEventListener("click",function(){e.querySelector(".dropdown").classList.toggle("open")})}),body.addEventListener("click",closeDropdowns),document.addEventListener("keydown",closeDropdowns),globalNav.addEventListener("click",function(e){let n=e.target;n.classList.contains("global-nav-track")&>mSendReport(n.text,n,"global-nav-link")}),module.exports=init;
}, {"1":1,"4":4,"12":12,"124":124,"135":135}];
window.modules["aaa-module-mounting.legacy"] = [function(require,module,exports){"use strict";const _pickBy=require(221),_each=require(406),Fingerprint2=require(408),DS=require(407),Eventify=require(246);function registerGlobals(){window.DS=DS,window.Eventify=Eventify,window.Fingerprint2=Fingerprint2,DS.value("Eventify",Eventify),DS.value("Fingerprint2",Fingerprint2),DS.value("$document",window.document),DS.value("$window",window)}function mountDollarSliceComponents(){DS.service("components",["$document","$module",function(e,n){var o=_pickBy(n.definitions,e=>e.providerStrategy===n.providers.controller),r=Object.keys(o);function t(e){return o=>{try{n.get(e,o)}catch(e){logMountError(o,e)}}}_each(r,n=>{var o=e.querySelectorAll('[data-uri*="/_components/'+n+'/"]'),r=e.querySelectorAll('[data-uri$="/_components/'+n+'"]');_each(o,t(n)),_each(r,t(n))}),this.components=r}]),DS.get("components")}function logMountError(e,n){const o=e.outerHTML.slice(0,e.outerHTML.indexOf(e.innerHTML));console.error("Error attaching controller to "+o,n)}registerGlobals(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{mountDollarSliceComponents()}):mountDollarSliceComponents();
}, {"221":221,"246":246,"406":406,"407":407,"408":408}];
window.modules["ads.legacy"] = [function(require,module,exports){"use strict";const _map=require(118),_forEach=require(107),_isString=require(268),_intersectionWith=require(409),_isEqual=require(274),_each=require(406),_debounce=require(182),_sortBy=require(205),page=require(124),visit=require(114);DS.service("adService",["Eventify","$cid","$document","$window",function(e,t,a,i){var o,n,s,r,d,c,u,l,g={},p=this,h=[],f=visit.getQueryParamsObject(["utm_campaign"]),m=document.querySelector('script[data-type="ad-a9"]'),b=[],w=!1,v=[],y=document.querySelector('script[data-name="ad-doubleverify"]');document.querySelector('script[data-name="concert-ads"]')||(i.NYM={},i.NYM.analytics={},i.NYM.analytics.adStartTime=i.performance.now(),i.googletag=i.googletag||{},i.googletag.cmd=i.googletag.cmd||[],u=i.googletag,(m||y)&&(i.googletag.cmd=i.googletag.cmd||[],i.googletag.cmd.push(function(){i.googletag.pubads().disableInitialLoad()})),m&&(l=i.setInterval(function(){void 0!==window.apstag&&void 0!==window.apstag.timeout&&(i.clearInterval(l),window.apstag.cleared=!0,l=null)},10),setTimeout(function(){l&&(i.clearInterval(l),i.googletag.pubads().refresh(),window.apstag||console.log("MESSAGE: Timeout for A9 load exceeded, aborting"))},500)),y&&(b.push(new Promise(function(e){w?e():v.push(e)})),c=i.setTimeout(T,2500)),o=function(e){var t,a,o=e.data,n=[];return o.loaded?e:(o.loaded=!0,t=null,(t=o.sizes?u.defineSlot(o.name,o.sizes,o.id).addService(u.pubads()):u.defineOutOfPageSlot(o.name,o.id).addService(u.pubads())).setTargeting("adid",o.id),f.hasOwnProperty("utm_campaign")&&t.setTargeting("utmcamp",f.utm_campaign),a=p.getAdCount(o.label),t.setTargeting("label",o.label+"_"+o.site+"-"+a),u.display(o.id),u.pubads().addEventListener("slotOnload",function(){i.NYM.analytics.firstAdLoadTime||(i.NYM.analytics.firstAdLoadTime=i.performance.now(),i.NYM.analytics.firstAdLoadLabel=e.data.label)}),n=_(o),Promise.all(b).then(function(){n?window.apstag&&window.apstag.cleared?window.apstag.fetchBids({slots:[n],timeout:window.apstag.timeout},function(){u.cmd.push(function(){window.apstag.setDisplayBids(),u.pubads().refresh([t],{changeCorrelator:!1})})}):y&&u.pubads().refresh([t],{changeCorrelator:!1}):u.pubads().refresh([t],{changeCorrelator:!1})}),e.slot=t,e)},n=function(e){var a,i,o,n=t(),s=e.getAttribute("data-name"),r=e.getAttribute("data-sizes"),d=e.getAttribute("data-label"),c=e.getAttribute("data-site");n=e.id,r&&r.length?(r=r.split(","),a=[],_map(r,function(e){e=e.split("x"),i=parseInt(e[0]),o=parseInt(e[1]),a.push([i,o])})):(e.classList.add("oop"),a=!1),this.data={id:n,name:s,sizes:a,loaded:!1,label:d,site:c},g[n]=this},r=function(e){u.cmd.push(function(){var t=o(e);g[e.data.id]=t})},s=function(e){var t=[];e.slot?(t=_(e))&&window.apstag&&window.apstag.cleared&&window.apstag.fetchBids({slots:[t],timeout:window.apstag.timeout},function(){u.cmd.push(function(){window.apstag.setDisplayBids(),u.pubads().refresh([e.slot],{changeCorrelator:!1})})}):e&&r(e)},u.cmd.push(function(){var e,t,o,n=page.getMeta("article:tag"),s=page.getMeta("author"),r=i.location.href,d=(e=a.head.querySelector(".head-gtm"),t=a.body.querySelector(".gtm"),e&&"top"===e.getAttribute("data-gtm")?"gtmtop":t&&"bottom"===t.getAttribute("data-gtm")?"gtmbottom":"");o=[],_forEach([n,s,d],function(e){_forEach(e.split(","),function(e){(e=e.trim().toLowerCase().replace(/\s/g,"-").replace(/\'|\’/g,"")).length&&o.push(e)})}),u.pubads().setTargeting("kw",o),u.pubads().setTargeting("entry_group",o),r=r.slice(r.lastIndexOf("/")+1),u.pubads().setTargeting("pn",r),u.companionAds().setRefreshUnfilledSlots(!0),u.pubads().enableAsyncRendering(),u.enableServices()}),this.load=r,this.create=function(e){return new n(e)},this.refresh=function(e){var t;_isString(e)?(t=this.getById(e),s(t)):s(e)},this.remove=function(e){var t=e.data.id;a.getElementById(t).innerHTML=""},this.getAdCount=function(e){var t,a=0,i=Object.keys(g);return _each(i,function(i){(t=g[i]).data.loaded&&t.data.label===e&&a++}),a},this.getById=function(e){return g[e]},d=_debounce(function(){var e={TopLeaderboard:1,RightColTopMPU:2,outOfPage:99,"homepageTakeover/TopLeaderboard":1},t=_sortBy(h,function(t){return e[t.data.label]||10});_forEach(t,function(e){return e.data.sizes?r(e):i.setTimeout(function(){r(e)},2e3)}),y&&window.PQ.cmd.push(()=>{try{window.PQ.loadSignals(["ids","bsc","vlp"],T)}catch(e){T(),console.error(`There has been an error loading Double Verify signals: ${e}`)}}),h=[]},10),this.addToPageLoadQueue=function(e){h.push(e),d()});function _(e){var t,a=e.sizes;return a=_intersectionWith(a,[[970,250],[970,90],[728,90],[300,600],[300,250],[320,100],[320,50]],_isEqual),e.sizes&&e.sizes.length&&(t={slotID:e.id,sizes:a,slotName:e.label}),t}function T(){i.clearTimeout(c),w=!0,_forEach(v,function(e){e()})}}]);
}, {"107":107,"114":114,"118":118,"124":124,"182":182,"205":205,"268":268,"274":274,"406":406,"409":409}];
window.modules["cid.legacy"] = [function(require,module,exports){"use strict";DS.service("$cid",function(){var r=Math.floor(100*Math.random());return function(){return"cid-"+ ++r}});
}, {}];
window.modules["client.legacy"] = [function(require,module,exports){"use strict";require("cid.legacy"),require("ads.legacy"),require("facebook.legacy"),require("aaa-module-mounting.legacy");
}, {"cid.legacy":"cid.legacy","ads.legacy":"ads.legacy","facebook.legacy":"facebook.legacy","aaa-module-mounting.legacy":"aaa-module-mounting.legacy"}];
window.modules["facebook.legacy"] = [function(require,module,exports){"use strict";DS.service("facebook",[function(){this.fb=function(i){window.FB&&window.FB[i].apply(this,Array.prototype.slice.call(arguments,1))}}]);
}, {}];
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o typeof key === 'string' && key.match(/\.legacy$/)).forEach(key => window.require(key));
}
function tryToMount(fn, el, name) {
try {
fn(el); // init the controller
} catch (e) {
const elementTag = el.outerHTML.slice(0, el.outerHTML.indexOf(el.innerHTML));
console.error(`Error initializing controller for "${name}" on "${elementTag}"`, e);
}
}
/**
* mount client.js component controllers
*/
function mountComponentModules() {
Object.keys(window.modules).filter(key => typeof key === 'string' && key.match(/\.client$/)).forEach(key => {
let controllerFn = window.require(key);
if (typeof controllerFn === 'function') {
const name = key.replace('.client', ''),
instancesSelector = `[data-uri*="_components/${name}/"]`,
defaultSelector = `[data-uri$="_components${name}"]`,
instances = document.querySelectorAll(instancesSelector),
defaults = document.querySelectorAll(defaultSelector);
for (let el of instances) {
tryToMount(controllerFn, el, name);
}
for (let el of defaults) {
tryToMount(controllerFn, el, name);
}
}
});
}
// Make sure that a `window.process.env.NODE_ENV` is available in the client for any dependencies,
// services, or components that could require it
// note: the `` value is swapped for the actual environment variable in /lib/cmd/compile/scripts.js
window.process = window.process || {};
window.process.env = window.process.env || {};
if (!window.process.env.NODE_ENV) {
window.process.env.NODE_ENV = '';
}
// note: legacy controllers that require legacy services (e.g. dollar-slice) must
// wait for DOMContentLoaded to initialize themselves, as the files themselves must be mounted first
mountLegacyServices();
mountComponentModules();
// ]]