Migrate Static Hosting to Netlify
On this page
- Before You Begin
- Netlify UI
- Import From a Git Repository
- Deploy Local Files
- Netlify CLI
- Set up the Netlify CLI
- Log in to Netlify
- Deploy manually with the CLI
- Setup continuous deployment
- Shut Down Atlas App Services Hosting
- Next Steps
- 404 Page and Redirects
- Update DNS Records
- Learn More About How Netlify Manages CDN Caching
- Invite Your Team
Important
Always refer to the official documentation of both MongoDB Atlas and Netlify for the most up-to-date and accurate information. Specific steps may vary depending on the details of your project and the technologies used.
Netlify is well-suited for hosting static websites and single-page applications (SPAs), and therefore will be compatible with your existing App Services application.
Netlify provides different methods to deploy your static websites depending on your needs. Connecting Netlify's CI/CD to your Git repository is ideal, but you can also deploy using a CLI, API, or even drag and drop. Below is an overview of methods that may be most helpful for developers currently using MongoDB Atlas hosting. See Netlify's full documentation on how to add a new site to explore all options in detail.
Before You Begin
As a precaution, ensure that you have a backup of your application and data before making any significant changes.
A git repository with your website code. Netlify's CI/CD integrates seamlessly with many popular Git providers. Even if you are not utilizing Netlify's CI/CD, it is highly recommended to use a version control system.
A Netlify account. Creating a new Netlify account is free and the signup flow should optionally walk you through the following process. The free tier should cover your hosting requirements when migrating from MongoDB Atlas hosting. If you need more services and features check out Netlify's Pro and Enterprise plans.
Netlify UI
You can use the Netlify UI to create and manage projects.
Import From a Git Repository
You can import an existing project from a Git repository and deploy it on Netlify. When you import your existing project repository, Netlify's continuous deployment will automatically update your site each time you push changes. To set up using the Netlify CLI, refer to the Netlify CLI section on this page.
To create a new site from a Git repo using the Netlify UI:
Go to your Netlify team's 'Sites' page, open the 'Add new site' menu, and select 'Import an existing project'.
Select the Git provider where your project is hosted.
Select your project's existing repository.
Adjust site and build settings.
Deploy Local Files
If you have an existing project on your local machine that isn't linked to a Git repository, you can manually deploy your site by using Netlify's deploy dropzone.
Go to your team's 'Sites' page, open the 'Add new site' menu, and select 'Deploy manually'. Drag and drop your site's output folder to the deploy dropzone to deploy your site.
Netlify CLI
Netlify's command line interface (CLI) lets you configure continuous deployment straight from the command line. You can use Netlify CLI to run a local development server that you can share with others, run a local build and plugins, and deploy your site manually.
Note
The following instructions are abbreviated to get you started migratingfrom MongoDB Atlas hosting. For advanced configuration see Netlify's full documentation for getting started with the Netlify CLI.
Log in to Netlify
Netlify CLI uses an access token to authenticate with Netlify. To authenticate and obtain an access token using the command line, enter the following command from any directory:
netlify login
This will open a browser window, asking you to log in with Netlify and grant access to Netlify CLI.
Deploy manually with the CLI
To deploy your application manually, without continuous deployment, run the following command from your project directory:
netlify deploy
The first time you run the command, Netlify CLI will prompt you to select an existing site or create a new one, linking the site for all future deploys.
Setup continuous deployment
For repositories stored on GitHub.com, you can use Netlify CLI to connect your repository by running the following command from your local repository:
netlify init
Netlify CLI will need access to create a deploy key and a webhook on the repository. When you run the command above, you'll be prompted to log in to your GitHub account, which will create an account-level access token. The access token will be stored in the Netlify CLI config.json. Your login password will never be stored.
Next Steps
If you need additional support for Netlify services, reach out to their support team.
404 Page and Redirects
You can set up a custom 404 page for all paths that don't resolve to a static file. This doesn't require any redirect rules. If you add a 404.html page to your site, it will be picked up and displayed automatically for any failed paths.
Netlify's redirect rules accept a number of options to customize how the paths are matched and redirected using the _redirects file syntax (see examples).
Update DNS Records
If your domain is currently pointed to MongoDB Atlas and you want to use the same domain with Netlify, update your DNS records to point to Netlify. See Netlify's documentation on configuring external DNS.
Learn More About How Netlify Manages CDN Caching
Static asset responses on Netlify are cached on Netlify's global edge nodes and automatically invalidated whenever a deploy changes the content. Static asset responses can only change with new deploys. For more advanced control of caching see Netlify's documentation on global caching infrastructure.
Invite Your Team
If you need to add someone to the team, you can set up role-based access controls that allow the Admin to take control and give access to individuals on the team. See Netlify's documentation on team management.