Bird
Raised Fist0
Astroframework~20 mins

Deploying to Vercel in Astro - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Astro Vercel Deployment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate
2:00remaining
What happens when you deploy an Astro project without a vercel.json file?

You deploy an Astro project to Vercel but do not include a vercel.json configuration file. What will be the behavior of the deployment?

AThe deployment fails because Vercel requires a vercel.json file for Astro projects.
BVercel automatically detects the Astro framework and builds the project correctly.
CThe project deploys but serves only static files without server-side rendering.
DVercel deploys the project but ignores all Astro components, showing a blank page.
Attempts:
2 left
💡 Hint

Think about how Vercel handles popular frameworks by default.

📝 Syntax
intermediate
2:00remaining
Which vercel.json configuration correctly sets the Astro build output directory?

You want to specify the output directory for your Astro build in vercel.json. Which configuration is correct?

A{ "builds": [{ "src": "package.json", "use": "@vercel/static-build", "config": { "distDir": "dist" } }] }
B{ "builds": [{ "src": "astro.config.mjs", "use": "@vercel/static-build", "config": { "output": "dist" } }] }
C{ "builds": [{ "src": "package.json", "use": "@vercel/node", "config": { "distDir": "dist" } }] }
D{ "builds": [{ "src": "package.json", "use": "@vercel/static-build", "config": { "outputDir": "dist" } }] }
Attempts:
2 left
💡 Hint

Check the property name that controls the output directory in Vercel's static build config.

🔧 Debug
advanced
2:00remaining
Why does the Astro project fail with 'Cannot find module' error after deployment?

After deploying your Astro project to Vercel, you get an error: Cannot find module '@astrojs/renderer-preact'. What is the most likely cause?

AThe <code>vercel.json</code> file incorrectly specifies the build command.
BVercel does not support Preact rendering in Astro projects.
CThe dependency '@astrojs/renderer-preact' is missing from <code>package.json</code> and was not installed.
DThe Astro project was built with an incompatible Node.js version on Vercel.
Attempts:
2 left
💡 Hint

Think about what causes module not found errors in deployed environments.

❓ state_output
advanced
2:00remaining
What is the output URL path for an Astro page at src/pages/blog/[slug].astro after deployment?

You have a dynamic route file src/pages/blog/[slug].astro in your Astro project. After deploying to Vercel, what URL path will serve the page for slug 'hello-world'?

A/blog/hello-world
B/blog/slug=hello-world
C/blog/[slug]/hello-world
D/blog/hello-world.astro
Attempts:
2 left
💡 Hint

Recall how dynamic route parameters map to URL paths in Astro.

🧠 Conceptual
expert
3:00remaining
How does Vercel handle server-side rendering (SSR) in Astro deployments?

Astro supports server-side rendering (SSR). When deploying an SSR Astro project to Vercel, how does Vercel execute the SSR code?

AVercel converts SSR Astro pages into static HTML files automatically.
BVercel pre-renders all pages at build time and disables SSR at runtime.
CVercel requires a separate backend server to handle SSR for Astro projects.
DVercel runs the SSR code as serverless functions triggered on each request.
Attempts:
2 left
💡 Hint

Consider how Vercel supports dynamic server code execution.

Practice

(1/5)
1. What is the main benefit of deploying an Astro site to Vercel?
easy
A. It makes your site live on the internet quickly.
B. It requires manual server setup and configuration.
C. It disables automatic SSL certificates.
D. It only works with static HTML files.

Solution

  1. Step 1: Understand Vercel's purpose

    Vercel is a platform that hosts websites and makes them accessible online quickly.
  2. Step 2: Identify the main benefit for Astro sites

    Deploying to Vercel allows your Astro site to be live on the internet fast without manual server setup.
  3. Final Answer:

    It makes your site live on the internet quickly. -> Option A
  4. Quick Check:

    Deploying to Vercel = Quick live site [OK]
Hint: Remember: Vercel makes sites live fast and easy [OK]
Common Mistakes:
  • Thinking Vercel requires manual server setup
  • Believing SSL is disabled by default
  • Assuming Vercel only supports static HTML
2. Which file should you include in your Astro project to configure Vercel deployment settings?
easy
A. package-lock.json
B. astro.config.js
C. vercel.json
D. index.html

Solution

  1. Step 1: Identify Vercel configuration file

    Vercel uses a special file named vercel.json to customize deployment settings.
  2. Step 2: Differentiate from other files

    astro.config.js configures Astro itself, package-lock.json manages dependencies, and index.html is a page file.
  3. Final Answer:

    vercel.json -> Option C
  4. Quick Check:

    Vercel config file = vercel.json [OK]
Hint: Vercel config always uses vercel.json file [OK]
Common Mistakes:
  • Confusing Astro config with Vercel config
  • Using package-lock.json for deployment settings
  • Thinking index.html controls deployment
3. Given this vercel.json snippet:
{
  "builds": [{ "src": "package.json", "use": "@vercel/node" }],
  "routes": [{ "src": "/api/(.*)", "dest": "/api/index.js" }]
}

What does this configuration do when deployed?
medium
A. It builds a Node.js serverless function from package.json and routes API calls to /api/index.js.
B. It serves static files only and ignores API routes.
C. It causes a deployment error due to invalid JSON syntax.
D. It disables all API routes and only serves the homepage.

Solution

  1. Step 1: Analyze the builds section

    The build uses @vercel/node with package.json, indicating a Node.js serverless function build.
  2. Step 2: Analyze the routes section

    Routes matching /api/(.*) are sent to /api/index.js, directing API calls properly.
  3. Final Answer:

    It builds a Node.js serverless function from package.json and routes API calls to /api/index.js. -> Option A
  4. Quick Check:

    Build + API routing = Node.js serverless function [OK]
Hint: Look for builds and routes keys to understand deployment behavior [OK]
Common Mistakes:
  • Assuming static files only without API support
  • Thinking JSON syntax is invalid here
  • Believing API routes are disabled
4. You deployed your Astro site to Vercel but get a 404 error on all pages. What is the most likely cause?
medium
A. You used an unsupported Node.js version in your project.
B. You forgot to set the build command in Vercel settings.
C. You did not connect your Git repository to Vercel.
D. Your vercel.json file has a syntax error.

Solution

  1. Step 1: Understand 404 error cause on Vercel

    A 404 on all pages usually means Vercel did not build the site correctly or serve the pages.
  2. Step 2: Check build command setting

    If the build command is missing, Vercel cannot build the site, causing 404 errors.
  3. Final Answer:

    You forgot to set the build command in Vercel settings. -> Option B
  4. Quick Check:

    Missing build command = 404 error [OK]
Hint: Always set build command in Vercel for Astro projects [OK]
Common Mistakes:
  • Assuming syntax error causes 404 instead of build failure
  • Thinking Git connection alone fixes 404
  • Blaming Node.js version without checking build
5. You want to deploy an Astro site with server-side rendering (SSR) on Vercel. Which step is essential to ensure SSR works correctly?
hard
A. Disable all API routes in vercel.json.
B. Only deploy static files without any server code.
C. Use a custom domain without connecting Git repository.
D. Set the output property to server in astro.config.mjs and use a compatible adapter.

Solution

  1. Step 1: Understand SSR requirement in Astro

    SSR requires Astro to output server code, not just static files.
  2. Step 2: Configure Astro for SSR deployment

    Setting output: 'server' in astro.config.mjs and using a Vercel adapter enables SSR.
  3. Final Answer:

    Set the output property to server in astro.config.mjs and use a compatible adapter. -> Option D
  4. Quick Check:

    SSR needs server output and adapter [OK]
Hint: SSR needs output: 'server' and adapter in config [OK]
Common Mistakes:
  • Deploying only static files for SSR
  • Disabling API routes unnecessarily
  • Ignoring Git connection for deployment
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard