How to import a link from database to Sanity project?

12 replies
Last updated: Jan 28, 2026
Hey guys! I want to import a link from my database to the project. What is the easiest and quickest way to do it?
AI Update

The easiest and quickest way to import data into your Sanity project depends on what you're importing, but here are your main options:

If you have data in NDJSON format (newline-delimited JSON), the CLI import command is your fastest route:

sanity dataset import <file> <targetDataset>

For example:

sanity dataset import my-data.ndjson production

Key things to know:

  • Each line in your NDJSON file should be a complete JSON document
  • Documents need a _type field (and optionally an _id)
  • For images/files, use the special _sanityAsset property: "image@file:///path/to/image.jpg" or "image@https://example.com/image.jpg"
  • You can import .ndjson files or .tar.gz archives (which include assets)

Useful flags:

  • --replace - Overwrites existing documents with the same _id
  • --missing - Only creates documents that don't exist yet
  • --allow-failing-assets - Continues import even if some assets fail

Run sanity dataset import --help to see all options.

Alternative: Using a Client Library

If you need more control or are importing from a custom source, you can use the Sanity JavaScript client with methods like client.create() or client.createOrReplace().

Important considerations when using the client:

  • Implement rate limiting (max 25 requests/second)
  • Use transactions for multiple mutations
  • Set visibility mode to deferred for large imports
  • Upload assets first, then reference them in documents

For a single link/document, you could also just create it directly in Sanity Studio if it's a one-off!

What type of data are you looking to import? That'll help determine the best approach.

Show original thread
12 replies

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?