Adding Client Side URL Params - Build a Single Page Application with JavaScript (No Frameworks)

  Рет қаралды 47,244

dcode

dcode

Күн бұрын

Пікірлер: 120
@netlity5532
@netlity5532 3 жыл бұрын
Very nice tutorial both part 1 and 2! I have understood quite well. I have a few questions though: 1. How to add a loading progress in case a view takes longer to be loaded 2. How to load a view which has some custom scripts and CSS files links in it Answers to these two questions will be much appreciated @dcode
@मेबीराज
@मेबीराज 2 жыл бұрын
Did you find any answer to 2nd question?
@chubbyBunny94
@chubbyBunny94 Жыл бұрын
i think these are pretty straight forward questions but yo, you've got chat GPT
@AyushSinghxda
@AyushSinghxda 3 жыл бұрын
After all these years of SPA, it finally makes sense how things work under the hood. Great work!
@flexDevelop
@flexDevelop 4 жыл бұрын
This is probably the most well done/explained video tutorial about SPA I've found in 2020. It's worth to mention the difference of how JS is processed on frontend JS files when compared with the server.js file (stuff such as require, etc). It would be also cool if you could do PWA integration (storage/websql). Keep up with the awesome work!
@dcode-software
@dcode-software 4 жыл бұрын
Appreciate that! Yes I've got a video on PWA but it could be an idea to combine the two 🤔
@fellipelorram4341
@fellipelorram4341 3 жыл бұрын
Definitely should do it
@amirhosseinveysi9546
@amirhosseinveysi9546 3 жыл бұрын
Changed my life sir, tnx for making this video
@slackergeek2007
@slackergeek2007 3 жыл бұрын
These 2 videos were great. I would love to see a continuation with the following: 1) pulling the HTML from there server using Fetch and a loading overlay and 2) rendering a 404 view for invalid routes. Or at the very least redirect back to Dashboard when the route is invalid.
@RashidAli-oc1sr
@RashidAli-oc1sr 2 жыл бұрын
Watch first part he told us about 404
@ginanjarseladipura3980
@ginanjarseladipura3980 4 жыл бұрын
this tutorial should have thousands of likes. thank you for doing this!
@atleast_me
@atleast_me 3 жыл бұрын
Long live js king 👑. This is the ultimate explained video I've found on KZbin
@ThaRealIansanity
@ThaRealIansanity 2 жыл бұрын
This is great! I've been learing react but for academic reasons I was working on a static site with alpinejs that uses the fetch api with laravel sanctum. After several frustrating days I managed a successful login but it is still just a static site. I think with all I learned from you I can move forward and make it an actual SPA. Thank you!
@Jangeroo
@Jangeroo 4 жыл бұрын
Really really great video. Also a great reminder to finally learn regex, it’s nothing but gibberish to me
@Rm-ey8xe
@Rm-ey8xe 4 жыл бұрын
Don't worry you still explained it well, Thank you very much for this great tutorial!
@vernatley221
@vernatley221 2 жыл бұрын
Great video and excellent teacher, for understanding how react works under the hood you leaves me feeling a little wiser. Ive one problem after following along. Dont want to just use your free code to understand why and how the problem exists. Everything is working exactly how should do apart from sometimes or mostly all times when traversing between links, the page is refreshing. Anyone?
@braddockbrawler
@braddockbrawler 6 ай бұрын
A third part would be nice, in which you connect to mysql, create posts, save posts and delete posts.
@braddockbrawler
@braddockbrawler 5 ай бұрын
1 month, no answer. This channel must be dead. Too bad, i liked it.
@socialpeople6615
@socialpeople6615 2 жыл бұрын
Fantastic tutorial! Very good explanation, good design and valuable material. Thank you!
@gustavoexel
@gustavoexel 4 жыл бұрын
Great video series, tks!!! One question: why don't we consider building the URLs with queries as "/posts?id=2&dcode=35" instead of "/posts/2/35" ? It'd be much clearer and easy to parse! Is there a definite reason why it's best not to use queries on SPA URLs?
@fomofonk
@fomofonk 2 жыл бұрын
Very informative videos (both 1 & 2)! I do have 1 question (and it might be a stupid one), how do you go about adding an actual post (like the ones shown at the beginning of this video)? (please excuse the beginner in me!)
@brandonjaus494
@brandonjaus494 4 жыл бұрын
Wow this was great! Thanks for the quality tutorial man; absolutely eye opening.
@2005Azm
@2005Azm 4 жыл бұрын
Simply awesome !
@robwatson826
@robwatson826 3 жыл бұрын
Now this has some clever stuff in it. I've always wondered but never actually looked into a client side routing engine before. Really good informative video and a nice solution. I didn't quite understand why right at the end you threw in that [location.pathname]? Seemed a bit rushed for no reason.
@yumdiddlyum
@yumdiddlyum 4 жыл бұрын
Great tutorial! The regex stuff is a bit over my head currently but you explained everything else clearly enough that I got a good overall idea of how it all works. Thanks for the video!
@dcode-software
@dcode-software 4 жыл бұрын
Appreciate it! Thanks Kayla great to see you enjoyed
@netlity5532
@netlity5532 3 жыл бұрын
@@dcode-software Very nice tutorial both part 1 and 2! I have understood quite well. I have a few questions though: 1. How to add a loading progress in case a view takes longer to be loaded 2. How to load a view which has some custom scripts and CSS files links in it Answers to these two questions will be much appreciated @dcode
@kamoroso94
@kamoroso94 10 ай бұрын
For the pathToRegex function, you could use named capture groups to avoid having to extract the names again from the path in getParams.
@amguruprasath8037
@amguruprasath8037 4 жыл бұрын
Man we need a full-fledged framework tutorial
@dcode-software
@dcode-software 4 жыл бұрын
Now that could quite possibly be re-inventing the wheel! Haha
@arshiagholami7611
@arshiagholami7611 3 жыл бұрын
@@dcode-software I see nothing wrong here
@jeffreyclaybrook
@jeffreyclaybrook Жыл бұрын
I'm trying to loop through an array of restaurant menu items (Posts) and dynamically generate a unique item details page (PostView) for each item rather than manually creating a PostView file for each item and was wondering if you could point me in the right direction for learning how to best implement this. This begs the question -- have you considered making a part 3 to this series of tutorials?
@russianstan
@russianstan 4 жыл бұрын
Thanks! It's just amazing!
@dcode-software
@dcode-software 4 жыл бұрын
All good!
@netlity5532
@netlity5532 3 жыл бұрын
@@dcode-software Very nice tutorial both part 1 and 2! I have understood quite well. I have a few questions though: 1. How to add a loading progress in case a view takes longer to be loaded 2. How to load a view which has some custom scripts and CSS files links in it Answers to these two questions will be much appreciated @dcode
@blarvinius
@blarvinius 3 жыл бұрын
Very clear and thorough. Thanks! (You move rather quick, so it might be nice to have your mouse cursor highlighted...)
@compsguru
@compsguru 2 жыл бұрын
Thanks for the tutorial , the first video was great . I just wish you didn;t get into the Regex area of it because it felt too advanced for the kind of people (me included) who are just starting off .
@vuejs1
@vuejs1 Жыл бұрын
What patterns are you using in this vid?
@arqasr
@arqasr 2 жыл бұрын
Hi, I love the two SPA videos, but I get stock. How I access the individual posts having a link on the Posts page? Do I need to create an individual file for each post? how?
@ГеоргиЧавдаров-в7з
@ГеоргиЧавдаров-в7з 4 жыл бұрын
You are awesome! You are master!
@Mickey_McD
@Mickey_McD 3 жыл бұрын
How might you extends your framework to handle form input when each view could have its own form? Maybe each post could allow for a user to add a comment?
@relaxingmusic6280
@relaxingmusic6280 3 жыл бұрын
Maybe use Ajax🤔
@marcelm7661
@marcelm7661 Жыл бұрын
Hi and thanks for the great vid! I learned a lot in this tutorial :) But I have one problem with my code. If i try to access to the /posts/:id route in my browser search bar I get a MIME Type error. If I am accessing it via link tag in my html it works totally fine. What could be a potential mistake I did?
@AleksandarIvanov69
@AleksandarIvanov69 4 жыл бұрын
So you if got an array of posts, you use this to populated the data from the array into the Post view, matching the post by id ?
@dcode-software
@dcode-software 4 жыл бұрын
Yep, pretty much!
@chimsgraphic
@chimsgraphic 3 жыл бұрын
Great video. How do I consumean api and pass to the view?
@vladosononame6376
@vladosononame6376 3 жыл бұрын
this video is piece of gold in sea of internet shit, works fine! good foundation!
@05060024
@05060024 2 жыл бұрын
Hi. I'm getting a strange behavior. If I insert a link inside the HTML returned by PostView.js, clicking on it shows the post as expected. However, if I enter the same URL localhost:5060/posts/23/4 in the address bar and hit enter, I still get one post displayed, but without any styling. When I look at the index.css returned in the Dev Tools, it has the contents that we put in index.html, instead. Any idea why this is happening?
@wewiwowo42
@wewiwowo42 2 жыл бұрын
Hello I have this exact issue Did you figure it out?
@wewiwowo42
@wewiwowo42 2 жыл бұрын
In dev tools as well as the index.html being loaded into the index.css the JS folder is not being laoded at all?
@wewiwowo42
@wewiwowo42 2 жыл бұрын
Hey buddy I fixed this issue in the end. It was due to the folder path syntax. instead of using just static/css/index.css for the href in the style sheet. re. begin the file path with ../ example
@koitaki
@koitaki 3 жыл бұрын
"Some people, when confronted with a problem, think ‘I know, I’ll use regular expressions.’ Now they have two problems." - Jamie Zawinski But for those confused, Dom has a good video on RegEx at kzbin.info/www/bejne/d6PbgK2bdrSBfsk
@nicolaschvostal
@nicolaschvostal 2 жыл бұрын
Why switching between dashboard posts and settings does not work for me, the dashboard will show, but when I press posts or settings it will show cannot get / posts or / settings. Thank you for support.
@amezan7777
@amezan7777 3 жыл бұрын
HI, great video! But I didn't understand how to add posts. Could you explain? Thanks :)
@Thanveershah
@Thanveershah 4 жыл бұрын
Is it a good practice to use SPA in Vanilla JS ? Looks so much complicated
@dcode-software
@dcode-software 4 жыл бұрын
For small projects, possibly - it's up to you. This is more for learning purposes 😁
@netlity5532
@netlity5532 3 жыл бұрын
@@dcode-software Very nice tutorial both part 1 and 2! I have understood quite well. I have a few questions though: 1. How to add a loading progress in case a view takes longer to be loaded 2. How to load a view which has some custom scripts and CSS files links in it Answers to these two questions will be much appreciated @dcode
@aguileraq
@aguileraq 4 жыл бұрын
Great video. I really hope you can complement this SPA with firebase auth, it will be great. Thanks!!
@iglesiasleonardo1742
@iglesiasleonardo1742 2 жыл бұрын
What if you need integration with a database? How will you manage both client and server-side? It can't be an app if it does not have any dynamic content
@youmee8956
@youmee8956 3 жыл бұрын
Would i get request and response (req, res) in routes path?
@KostasOreopoulos
@KostasOreopoulos 4 жыл бұрын
With a few tweaks it can be made easier to understand and more compact we have as in the code const pathToRegexForValues = (path) => new RegExp('^' + path.replace(/\//g, '\\/').replace(/:\w+/g, '(.+)') + '$'); and we can define const pathToRegexForKeys = (path) => new RegExp('^' + path.replace(/\//g, '\\/').replace(/:\w+/g, ':(.+)') + '$'); which does almost the same but leaves out the : from the regExpression with the intention to capture just the name So now when we match we have return { route: route, matchedParamValues: location.pathname.match( pathToRegexForValues(route.path) ), // this is the same matchedParamKeys: route.path.match(pathToRegexForKeys(route.path)), // here we go the path we are looking for '/posts/:id' and extract everything after the : // for each occurence of : }; Everything else is the same. Now we go to the getParams function and we will have values = match.matchedParamsValues.slice(1) ; // since we renamed result to matchedParamValues keys = match.matchedParamsKeys.slice(1) ; and everything else stays the same.
@romuloalves9349
@romuloalves9349 4 жыл бұрын
Ótimo vídeo parabéns 👏.
@wewiwowo42
@wewiwowo42 2 жыл бұрын
Thoroughly enjoyed this video and found it very helpful thankyou. I did get stuck however with the pathToRegex. I get the following error when I try to go to localhost:5500/posts/2 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec. did anyone come across this ISSUE SORTED ALL GOOD
@daredevil_37
@daredevil_37 Жыл бұрын
getting the same error, how did you manage to solve it?
@rogerchan548
@rogerchan548 Жыл бұрын
Having th same issue. How did you solve it?
@5ikronoz
@5ikronoz 3 жыл бұрын
รอ SPA #3 อยากรู้ว่าจะนำข้อมูลจาก data base มาแสดงใน SPA นี้ยังไง
@mingmeng030
@mingmeng030 2 жыл бұрын
This is perfect tutorial for me! But I have an issue. My router works fine, but when I switch the page to postView, css isn't being applied at all. Does anyone know about this issue?!
@wewiwowo42
@wewiwowo42 2 жыл бұрын
I have this same issue Did you find a dix
@mingmeng030
@mingmeng030 2 жыл бұрын
@@wewiwowo42 not yet,,I searched everywhere but there’s nothing can help me. I think it can be react’s error
@wewiwowo42
@wewiwowo42 2 жыл бұрын
@@mingmeng030 I actually figured it out. It was the syntax for me with the link ref for the style sheet. I had to use ../ at the start of the file path. Instead of just static/css/.index.css try ../static/css/index.css
@mingmeng030
@mingmeng030 2 жыл бұрын
@@wewiwowo42 omg you saved me!! It also worked at my issue!! Thanks:)
@wewiwowo42
@wewiwowo42 2 жыл бұрын
@@mingmeng030 awesome.
@shvrolet
@shvrolet Жыл бұрын
i have one question. when i go /post/2 that's work but when i refresh the page all css is gone.Why that's happening?
@erfelipe
@erfelipe 3 жыл бұрын
Thanks
@_.sunnyraj._
@_.sunnyraj._ 4 жыл бұрын
Please make a video on passport login using node
@adityamalviya5113
@adityamalviya5113 3 жыл бұрын
Very Informative video . Really very nice concept implemented . I am trying to make a web application referring your video . Thank you for the video . Trying to implement there's a problem came in front of me , When I navigate to dashboard/0 , the address of all static files changes . Mean to say , when the url is 'localhost:5000/dashboard/0' , then Images , css files which are having path 'localhost:5000/static/images/abc.png' changes to 'localhost:5000/dashboard/static/images/abc.png' , hence image doesn't displays in 'localhost:5000/dashboard/0' page . I just wanted to know , why this is happening ?
@dcode-software
@dcode-software 3 жыл бұрын
I made a video on this a while ago: kzbin.info/www/bejne/nIvNfJZooLJ-j7c
@adityamalviya5113
@adityamalviya5113 3 жыл бұрын
​@@dcode-software Thank you for the reply . I now got understood what I was doing wrong . Thank you .
@adityamalviya5113
@adityamalviya5113 3 жыл бұрын
I came up with another question If you don't mind , I wants to know how to deploy this app on firebase . Having server.js and index.js both running . I hosted it on firebase the simple way any normal website is hosted . And after hosting it I found that index.js is running and server.js file is not running because redirecting after login failed which should reach to server.js . Instead 404.html is called . Observing this I can say that server.js is not running . How to host the application such a way that server.js should run along with index.js ?
@mr.o5577
@mr.o5577 3 жыл бұрын
Hi Dom sorry to bother mate but I have a bit of an issue, can you help? I built a SPA just like yours but now I face the deployment problem, now, how can I deploy a SPA just like the one you build on netlify or heroku? My problem is that the app has a backend where the routes are and the app needs it in order to hit the routes, i deployed all the files to netlify and heroku but no good, what to do? If anyone besides Dom in here knows please help me I am at lost.
@olutolamoses4416
@olutolamoses4416 3 жыл бұрын
I am having issues accessing the view pages In the dom. please assist
@rangabharath4253
@rangabharath4253 4 жыл бұрын
awesome
@richardprakash4630
@richardprakash4630 3 жыл бұрын
how do we handle JS in the views? example click event of a button
@casm101
@casm101 3 жыл бұрын
I've been making a site with this SPA method, and the solution is actually quite easy, after you run the router function on after the dom has loaded, you just need to run a function to apply your event listeners to current page, you can even pass the current path through the new function as a parameter to only load certain event listeners depending on the view you are loading!
@devindickerson9699
@devindickerson9699 2 жыл бұрын
@@casm101 any chance you could tell me more how you handled the event listeners? I've been building a site with this method also and I'm am struggling with the event listeners for the views.
@casm101
@casm101 2 жыл бұрын
@@devindickerson9699 Hi, of course! I did it the following way: I have a separate file where I manage ONLY event listeners (for comodity, but you don't have to) and all the listeners are wrapped in a window.onload function to make sure they execute when everything is available, and inside I separate my listeners in groups that check if they correspond to the current site path, if so, they run, if not, they don't! Another way is to check if the element you wish to apply the listener to is visible on screen or not, which may be a better technically, depending on your application... Sorry for the late reply
@wewiwowo42
@wewiwowo42 2 жыл бұрын
@@casm101 any chance of sharing the code you wrote for passing event listeners to the current page, I'm getting stuck trying to wrap my code in a window onload event function. I am still learning JS,. I keep on getting ye old 'cannot read properties of null'?
@wewiwowo42
@wewiwowo42 2 жыл бұрын
Actually I fixed the Null reading error. for the window event listener. Though I am stuck on how pass the page path through so the click event wrapped inside works THIS IS my Code for handling the event I a huge Noobie. NAy help could be appreciated. window.addEventListener("onload", () => { if (route.path === ("/article")) { const techbtn = document.getElementById("techbtn"); const techinfo = document.getElementById("techinfo"); techbtn.addEventListener("click", () => { techinfo.classList.remove("nonvisible"); techinfo.classList.add("visible"); }); } });
@maheshYchhetri
@maheshYchhetri 3 жыл бұрын
My page getting error when change route to /about and reload the page How can i fix this?
@Jangeroo
@Jangeroo 4 жыл бұрын
What the router misses tho: route /posts/:id fully blocks /posts/:id/addComment
@hartono9583
@hartono9583 Жыл бұрын
need tutorial how to run js script and fetch api in page example product.html ?
3 жыл бұрын
Where i can download the code?
@amguruprasath8037
@amguruprasath8037 4 жыл бұрын
how many more videos in this series?
@dcode-software
@dcode-software 4 жыл бұрын
As for right now, this is the last one.
@mohamedshehata3979
@mohamedshehata3979 Жыл бұрын
how can i find Github Repo??
@anjanspace
@anjanspace 4 жыл бұрын
Hi , I am having problem in loading multiple HTML pages . Can you please help me. Is there any possibility of connecting with you via google meet. Pleaseeeee
@KostaTsourdalakis
@KostaTsourdalakis 4 жыл бұрын
First! YADIGG
@urekmazino2086
@urekmazino2086 2 жыл бұрын
Anyone else has the .matchAll(...).map() is not a function
@braswelljr
@braswelljr 4 жыл бұрын
finally
@heruhailiuhuang533
@heruhailiuhuang533 2 жыл бұрын
Nice vieos.
@yashrajjaiswal9941
@yashrajjaiswal9941 2 жыл бұрын
🙏
@devindickerson9699
@devindickerson9699 2 жыл бұрын
looking for anyone who know how to add event listeners to the html in each view
@_.sunnyraj._
@_.sunnyraj._ 4 жыл бұрын
Second !!!!!
@zakur0hako
@zakur0hako 2 жыл бұрын
i guess this is not for beginners. regexp part is confusing as hell
3 жыл бұрын
Sorry but second part is really complicated
@ashiqurrahmantahmid9634
@ashiqurrahmantahmid9634 3 жыл бұрын
All I hear is right here xD
@remco_smits
@remco_smits 3 жыл бұрын
`no framework` NODE JS IS A FRAMEWORK DOGGGG
@christianf7740
@christianf7740 3 жыл бұрын
"new match.route.view" - this is why I prefer typescript. So confusing.
@tangkasr2132
@tangkasr2132 Жыл бұрын
Hi and thanks for the great vid! I learned a lot in this tutorial :) But I have one problem with my code. If i try to access to the /posts/:id route in my browser search bar I get a MIME Type error. If I am accessing it via link tag in my html it works totally fine. What could be a potential mistake I did?
@aguileraq
@aguileraq 4 жыл бұрын
Great video. I really hope you can complement this SPA with firebase auth, it will be great. Thanks!!
Using the History API - JavaScript Tutorial
16:40
dcode
Рет қаралды 33 М.
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
Vanilla JS Single Page Application Routes | # or URL  - #88
33:38
How to Build a Kanban Board with JavaScript (No Frameworks)
1:25:39
How to Use Local Storage in JavaScript
15:23
dcode
Рет қаралды 286 М.
How to create a Web Component using Vanilla JS
17:45
A shot of code
Рет қаралды 68 М.
Sleek & Simple Login and Sign Up Form in HTML, CSS & JS
47:39
Web Components Crash Course
28:54
Traversy Media
Рет қаралды 257 М.
Laravel 11 + React Full Stack App with Inertia - Project Management App
5:44:19
This is the Only Right Way to Write React clean-code - SOLID
18:23
Multi page vs Single Page Applications  - Which One Is Right For You?!
15:00
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19