⚠️ This lesson is retired and might contain outdated information.

Use Zeit’s Now to point a custom name to a specific deployment

Share this video with your friends

Social Share Links

Send Tweet
Published 8 years ago
Updated 3 years ago

Because now deploys are immutable, you can’t push changes to a running instance - you just push a new instance, which means you get a new URL. But doesn’t that mean your URL is always changing? How do you share a link to your application? By using now alias to point a custom name to a specific deployment.

[00:00] Now's immutable deploys are powerful. To remind you what we're talking about, let's say I deploy a given instance of my application. I'm going to get a URL for it, and then I make some kind of a change. Let's say, we're going to go back to the retro Hello World! Instead of Hello Universe! And then deploy it.

[00:20] I'm going to get a new URL. There's my old one. There's my new one. Let's go visit the old one first. That's going to say Hello Universe! And then let's grab this one. That's going to say Hello World! That's the problem. Which URL should my customers be going to? I'm confused now. What should I do?

[00:49] The answer is neither. Obviously, you don't want to share a URL that looks like this. Instead, we're going to do something. We're going to create a Now alias which is built-in support for this and this is an important part of the Now workflow.

[01:03] To use it, we're going to type now alias, and then we're going to paste the URL that we want to be pointing to. In this case, it's our most recent deploy, and then we're going to give it a name. In this case, let's say egghead-course. Now, look what it said. It says Alias created https://egghead-course.now.sh.

[01:27] Now, if I go here to egghead-course.now.sh, I see that I'm getting the same thing that I was getting here. Great. I can alias to a URL. How does that actually help me solve my problem? The trick is that I never give this URL to anyone ever. This is internal. This is a reference.

[01:55] Think of this as almost like a git commit hash. That's effectively what this is. This is a specific snapshot of my logic and I don't want any of my customers to be looking at snapshots. What I want them to be looking at is a nice user-friendly URL.

[02:09] Let's say I go through then and I make some more edits. I say Hello World! I add a paragraph here. This is a new paragraph of content! I'm going to deploy this. I'm going to get yet another URL. That's running. Let's paste that new URL in here. This is a new paragraph of content!

[02:42] There's our old one. There's our new one. Our alias is still pointing at the old one, so this is crucial. Once I see that this deployment works the way I expect it to work, all I have to do is go back and type now alias with the new URL, the name egghead-course.

[03:04] What that's going to do is change the pointer. Now, when I refresh egghead-course, it's now pointing at this new endpoint instead of at the old one. This is how this works with immutable deploys. You have any number of these instances that are spun-up, deployed, and running around in the wild, but the alias is the thing that you care about.

[03:28] On a free account, this is totally free. You get your 20 deploys a month for free right now as of this recording. You're allowed to alias to any phrase and the URL that you get is going to be that phrase.now.sh.

egghead
egghead

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today