Vercel Python Import Error Helper function
Python helper function for making it work both locally and on Vercel is to correctly determine the project's root directory, as Vercel's serverless environment can change the working directory.
Python helper function for making it work both locally and on Vercel is to correctly determine the project's root directory, as Vercel's serverless environment can change the working directory.
The primary cause for import errors on Vercel is often a mismatch between your local development environment's flexibility and Vercel's strict, serverless build process. Beyond the crucial __init__.py
file, you need to pay attention to your project's overall structure, the way you write imports, and Vercel's build configuration.
Vercel doesn't have a single, built-in migration system but instead relies on standard, database-specific tools. For relational databases like Vercel Postgres, you use traditional ORMs or migration libraries. For key-value stores like Vercel KV, migration is typically a manual process of data transformation.
Vercel provides a streamlined way to integrate databases into your projects, focusing on a serverless and edge-centric approach. Instead of a single database, Vercel offers a suite of storage solutions, each optimized for different use cases. The integration process is designed to be seamless, with first-class support for a range of serverless databases [1].
No, SQLite is not officially supported by Vercel for production applications because of its reliance on the local filesystem. Vercel's serverless functions are stateless and run in a read-only environment, meaning any changes to the local filesystem are discarded after the function's execution. This makes it impossible to persist the SQLite database file between function invocations. Vercel source
While you might be able to get a read-only SQLite database to work by including the database file in your deployment bundle, any attempt to write to it will fail. This limitation makes SQLite unsuitable for most dynamic web applications on the Vercel platform.
Vercel provides a suite of data storage solutions designed to complement its serverless and edge-first architecture. Instead of a single "Vercel Database," you get a selection of tools, each optimized for a specific use case. This allows you to choose the right database for the job, whether it's a simple key-value store or a full relational database.
If you're at a point where you want to build a site that goes beyond just a portfolio or a blog—something you might monetize, track analytics on, add dynamic features to, or even scale up into something bigger—it’s important to choose your hosting platform wisely. GitHub Pages and Vercel are both wildly popular options, but they offer fundamentally different experiences once you want to do more than just put HTML online.
🔄 Update to: Count Number of Blog Posts in Docusaurus and Vercel
In my previous post, I shared a method to count the number of docs posts in a Docusaurus project and display it on your homepage, fully compatible with Vercel and static builds.
That method works great—if all your docs posts are plain .md
or .mdx
files in the docs/
directory.
But if you're like me and prefer organizing docs posts in folders (e.g., docs/folder/index.md
), the previous approach silently misses those.
🔄 Update to: Count Number of Blog Posts in Docusaurus and Vercel
In my previous post, I shared a method to count the number of blog posts in a Docusaurus project and display it on your homepage, fully compatible with Vercel and static builds.
That method works great—if all your blog posts are plain .md
or .mdx
files in the blog/
directory.
But if you're like me and prefer organizing blog posts in folders (e.g., blog/my-post/index.md
), the previous approach silently misses those.
If you're building on Hrekov.com or your next side project, picking a good free-tier database can make or break your MVP. Here's a detailed look at what Vercel (via Neon) and Supabase offer with no cost, along with the trade-offs.