Monday, February 13th 2017 (over 2 years ago)

An Easier Way to Alias

Leo Lamprecht (@notquiteleo)

Today I'd like to take some time and sum up the updated capabilities of Now and what's needed for properly handling the process of moving a project to the production stage.

In addition, this post will teach you how to alias instantly by running now alias and customizing your config.

Staging and Why It's Important

At the core of the philosophy behind Now are immutable deployments.

This means that each time you run now, you get a new deployment (rather than updating an existing one). Its URL will be copied to your clipboard automatically, letting you share it right away.

This basically provides our users with a secure sandbox right before the production level. Why?

  • Avoids bugs from getting dragged onto production
  • Allows you to share the changes with testers around the globe using a unique unguessable URL
  • Simulates the production enviroment exactly
  • Several optimizations are in place to make deploying virtually instant

As you can see, staging your application before "moving it" to production using now alias comes with many neat benefits. Therefore, it's generally a good practise to take advantage of this functionality!

Aliasing Automatically

For most projects, the production domain always stays the same. This results in you having to run now alias over and over again with the same values.

To automate this, we recently introduced the alias property for your package.json or now.json file. The property either accepts a string containing a single alias:

"alias": "zeit.chat"

Or an array with multiple aliases in it:

"alias": [
"zeit.chat",
"chat.zeit.co"
]

Independent from the value type you've chosen, all of the aliases listed there will be assigned to the most recent deployment when now alias (without any arguments) is run.

Each time you run the command, the alias will get copied to your clipboard (now will pick the last one if your alias property contains multiple ones).

It also doesn't matter if the alias already exists or not. If it doesn't, Now will create it and lead you through the steps required for connecting the domain. Easy as pie, isn't it?